Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

github actions: using variables in global env section

Is it possible to use variables inside global env sections in github workflows? Something like following code snippet

env:
  isqa: ""
  local_tag: "${{env.isqa}}latest"
  project: "important"
  aws_taskdef: "project-${project}-something"
like image 826
libxelar.so Avatar asked May 18 '26 17:05

libxelar.so


1 Answers

You cannot put these env references on the same level, but you can specify the to-be-referenced values on the workflow or job level, and reference them in the step level. It would be something like this

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"

You can see my testing in here, https://github.com/chenrui333/github-action-test/blob/main/.github/workflows/env-test.yaml

like image 155
chenrui Avatar answered May 21 '26 13:05

chenrui



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!