How do you pass data from a step in one job to a step in another job?
BeginnerConceptContexts, Expressions, Env & Outputs
Answer
Three hops: step output to job output to needs.
jobs:
version:
runs-on: ubuntu-24.04
outputs:
semver: ${{ steps.v.outputs.semver }}
steps:
- id: v
run: echo "semver=1.4.$GITHUB_RUN_NUMBER" >> "$GITHUB_OUTPUT"
build:
needs: version
runs-on: ubuntu-24.04
steps:
- run: echo "Version ${{ needs.version.outputs.semver }}"
For files, use artifacts.
More on Contexts, Expressions, Env & Outputs
List the available contexts and what each holds.BeginnerWhich contexts can you use in which keys? Give two examples that trip people up.AdvancedWhat are the expression operators and how do comparisons coerce types?IntermediateHow do you write a ternary in GitHub Actions expressions?IntermediateWhat do `contains`, `startsWith`, `endsWith`, `format` and `join` do?BeginnerWhat are object filters (`.*`) and how are they useful?Intermediate