Skip to content

Modify environment variable for entire workflow #26957

Answered by BrightRan
AlishStrong asked this question in Actions
Discussion options

You must be logged in to vote

@alishstrong ,

You can use the outputs to pass the updated value of the environment variable from job-1 to job-2.

I have tested the following example, it can work fine as expected (see here):

env:
  TEST_RESULT: 'success'

jobs:
job1:
name: Change env variable

# set job-level output and pass the value of step-level output to it
outputs:
  test-result: ${{ steps.set_outputs.outputs.test-result }}

runs-on: ubuntu-latest
steps:
  - name: Print value of env variable
    run: echo "TEST_RESULT = $TEST_RESULT"

  - name: Change env variable
    run: echo "::set-env name=TEST_RESULT::failure"

  - name: Print new value of env variable
    run: echo "TEST_RESULT = $TEST_RESULT"

  # set step-leve…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants