🎓 A1Learner
🔍
0 of 50 lessons completed

GitHub Actions: Outputs and Passing Data Between Jobs

A job output is a named value that one job passes to another job. It lets a later job use a result from an earlier job.

Set an output in a step

Give the step an id. Write the value to $GITHUB_OUTPUT.

- id: version
  run: echo "app_version=1.0.0" >> "$GITHUB_OUTPUT"

Declare the output on the job

The job maps its output name to the step output.

outputs:
  app_version: ${{ steps.version.outputs.app_version }}

Read the output in a later job

The later job needs the first job. Then it reads the value.

print:
  needs: build
  steps:
    - run: echo "${{ needs.build.outputs.app_version }}"

Example

name: Outputs demo
on:
  push:
    branches: [main]
jobs:
  build:
    runs-on: ubuntu-latest
    outputs:
      app_version: ${{ steps.version.outputs.app_version }}
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-node@v7
        with:
          node-version: '24'
      - run: npm test
      - id: version
        run: echo "app_version=1.0.0" >> "$GITHUB_OUTPUT"
  print:
    runs-on: ubuntu-latest
    needs: build
    steps:
      - run: echo "The demo app version is ${{ needs.build.outputs.app_version }}"

Key points

  • Use a job output to share one small value between jobs.
  • A step sets an output by writing a name and value to $GITHUB_OUTPUT.
  • The job declares the output in an outputs block.
  • A later job reads the value with needs and the job name.
  • A job can only read an output from a job it needs.
  • A job output holds text, like a version number or a file name.

In this example, the build job checks out the code and sets up Node 24. It runs the tests, then the version step writes app_version to $GITHUB_OUTPUT. The job declares that value in its outputs block. The print job needs the build job, so it runs after it. Its step reads needs.build.outputs.app_version and prints the version.

Note

Outputs do not carry files between jobs. Use an artifact for files.

Try it Yourself

Edit the code, then press Run.

Running is simulated · Rust Playground

Exercise

A build job sets an output named app_version. How does a later job read it?