Passing Variables Between jobs #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Passing Variables Between jobs | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| producer: | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| foo: ${{ steps.generate-foo.outputs.foo }} | |
| steps: | |
| - name: Generate and export foo | |
| id: generate-foo | |
| run: | | |
| foo=bar | |
| # 1) Step output (for job output) | |
| echo "foo=${foo}" >> "$GITHUB_OUTPUT" | |
| # 2) Job-scoped environment variable | |
| echo "FOO=${foo}" >> "$GITHUB_ENV" | |
| - name: Inspect values inside producer | |
| run: | | |
| echo "FOO (set via GITHUB_ENV): $FOO" | |
| echo "foo (step output): ${{ steps.generate-foo.outputs.foo }}" | |
| consumer: | |
| runs-on: ubuntu-24.04 | |
| needs: producer | |
| steps: | |
| - name: Inspect values inside consumer (note FOO is unset) | |
| run: | | |
| echo "Value from producer: ${{ needs.producer.outputs.foo }}" | |
| echo "FOO in consumer: ${FOO:-<UNSET>}" |