Update workflow level env variable GitHub Actions

Viewed 6

I need to update the workflow level environment variables to use the updated values in a second job but I am having trouble doing this as the changes I make a reset between jobs

name: build and release

on:
  workflow_dispatch:

env:
  A: 1
  B: 2
  C: 3

jobs:
  set_environment:
    runs-on: ubuntu-latest
    steps:
      - name: update workflow level env
        run: |
          echo "A=one" >> $GITHUB_ENV;
          echo "B=two" >> $GITHUB_ENV;
          echo "C=three" >>$GITHUB_ENV;
      
      - name: output new env
        run: |
          echo $A
          echo $B
          echo $C

  test_output:
    runs-on: ubuntu-latest
    needs: set_environment
    steps:
      - name: output new env in next job
        run: |
          echo $A
          echo $B
          echo $C

Action Result

Any help would be greatly appreciated, I tried using the set-env action on the marketplace but I wasn't able to get it working

0 Answers
Related