rhysd / actionlint

:octocat: Static checker for GitHub Actions workflow files
https://rhysd.github.io/actionlint/
MIT License
2.82k stars 156 forks source link

The env reference cannot happen on the same level #74

Open chenrui333 opened 3 years ago

chenrui333 commented 3 years ago

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

rhysd commented 3 years ago

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 commented 3 years ago

I made a question at the forum.

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

catthehacker commented 2 years ago

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