actionlint icon indicating copy to clipboard operation
actionlint copied to clipboard

The env reference cannot happen on the same level

Open chenrui333 opened this issue 4 years ago • 3 comments

The env variable cannot reference another env variable at the same level, for example, it wont work like this

env:
  IS_QA: "qa"
  PROJECT: "important"
  LOCAL_TAG: "${{env.IS_QA}}-latest"
  AWS_TASKDEF: "project-${{env.PROJECT}}-something"

But it can be put into different levels as below would work

jobs:
  test:
    runs-on: ubuntu-latest
    env:
      IS_QA: "qa"
      PROJECT: "important"
    steps:
      - run:
          echo ${{env.IS_QA}}
          echo ${{env.LOCAL_TAG}}
          echo ${{env.PROJECT}}
          echo ${{env.AWS_TASKDEF}}
        env:
          LOCAL_TAG: "${{env.IS_QA}}-latest"
          AWS_TASKDEF: "project-${{env.PROJECT}}-something"

so ref, https://stackoverflow.com/questions/69979085/github-actions-using-variables-in-global-env-section

chenrui333 avatar Nov 16 '21 01:11 chenrui333

Is this guaranteed to be valid? Since xxx: is a key of mapping object, order of evaluation of keys is not guaranteed I think. In YAML semantics, order of keys of mapping object is undefined. For easier example, order of keys of JSON object is not deterministic. In your example, is it guaranteed that the evaluation of LOCAL_TAG: ... happens before the evaluation of AWS_TASKDEF: ...?

rhysd avatar Nov 16 '21 06:11 rhysd

I made a question at the forum.

https://github.community/t/spec-about-the-order-of-evaluation-of-mapping-values/212889

rhysd avatar Nov 18 '21 09:11 rhysd

I would recommend asking in https://github.com/actions/runner repository

catthehacker avatar Nov 28 '21 12:11 catthehacker