0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

GitHubActionsの環境変数は大文字に変換されない

Posted at

公式には以下のように記載されています。

GitHub converts environment variables names to upper case. For example, if you set the variables first_name, middle_name, and last_name for a step in your workflow, you could read the FIRST_NAME, MIDDLE_NAME, and LAST_NAME environment variables.

steps:
  - name: Hello world
    run: echo Hello world ${FIRST_NAME} ${MIDDLE_NAME} ${LAST_NAME}!
    env:
      first_name: Mona
      middle_name: The
      last_name: Octocat

が、実際には大文字小文字は区別されるようです。

記述

    - name: Test
      run: |
        echo "1-1: $KEY1"
        echo "1-2: ${KEY1}"
        echo "1-3: $key1"
        echo "1-4: ${key1}"
        echo "2-1: $KEY2"
        echo "2-2: ${KEY2}"
        echo "2-3: $key2"
        echo "2-4: ${key2}"
      env:
        key1: value
        KEY2: VALUE

実行結果

1-1: 
1-2: 
1-3: value
1-4: value
2-1: VALUE
2-2: VALUE
2-3: 
2-4: 

しばらくハマってしまいました。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?