17
8

More than 3 years have passed since last update.

【Github Actions】独自の環境変数設定方法

Posted at

概要

ymlファイルに書きたくないTokenなどをGithub ActionsのJobで使いたい時の方法

変数をGithubの設定に追加

Github Actionsを設定したいrepoのSettings > Secretsにアクセスします。
image.png

アクセスをしたら、Add a new secretをクリックして、変数を追加出来ます。

変数名は大文字で登録しましょう。

job定義ファイルで環境変数を使用する

Githubのsettinsで設定した環境変数はymlファイルに以下のような形で展開できます。
例: HOGE_TOKENのような環境変数を設定したとします。

run: hoge --token=${{ secrets.HOGE_TOKEN }}

のようにして使用することが出来ます。

17
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
8