Use jobs.<job_id>.environment
to define the environment that the job references.
|
Provide the environment as the environment name
—either as a literal string or as an expression that resolves to a name:
environment: dev
environment: ${{ inputs.target_env }}
If you use the Register an artifact deployed to an environment action in a workflow run, its target-environment value overrides jobs.<job_id>.environment .
|
Using job.environment
in called workflows
Use job.environment
to pass the current job’s evaluated environment name to a reusable workflow, avoiding hard-coded strings.
deploy: uses: org/repo/reusable.yaml environment: QA secrets: asecret: ${{ secrets.secret1 }} with: aninput: ${{ vars.avalue }} artifactName: ${{ inputs.artifactName }} artifactVersion: ${{ inputs.artifactVersion }} environment: ${{ job.environment }} # resolves to "QA"
deploy: uses: org/repo/reusable.yaml environment: ${{ inputs.target_env }} # for example: "QA", "staging", "prod" with: environment: ${{ job.environment }} # returns the evaluated name