quickstart →

Pass data between jobs in GitHub Actions: GITHUB_OUTPUT

Pass a value or a file between steps and jobs: $GITHUB_OUTPUT, job outputs with needs, $GITHUB_ENV, artifacts, matrix outputs and size limits.

Most non-trivial workflows need to move a value from one place to another: a version number computed in one step, a build matrix generated by an early job, a compiled binary handed off to a deploy job. GitHub Actions gives you a few distinct mechanisms for this, and picking the right one matters. In this article you’ll learn the modern, supported ways to pass data — between steps in the same job, between separate jobs, and across entire runs — along with when to reach for each.

A quick note before we start: if you’ve seen older tutorials using ::set-output:: or ::save-state::, those workflow commands are deprecated. As of November 2026 they still work, but the runner can log a warning that they will be disabled. Use the environment files instead: everything below uses $GITHUB_OUTPUT and $GITHUB_ENV, and $GITHUB_STATE replaces save-state inside actions.

Step outputs: passing data between steps with $GITHUB_OUTPUT#

The smallest unit of data passing is a step output. A step writes a name=value pair to the special file referenced by $GITHUB_OUTPUT, and later steps read it back through the steps context — as long as the producing step has an id.

.github/workflows/ci.yml
name: Step outputs
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Compute a version
id: version
run: echo "value=1.4.2" >> "$GITHUB_OUTPUT"
- name: Use the version
env:
VERSION: ${{ steps.version.outputs.value }}
run: echo "Building version $VERSION"

The key pieces:

  • The producing step must declare an id (version above). Without it, there’s no handle to read from.
  • You append name=value to $GITHUB_OUTPUT — always quote the variable so a path with spaces won’t break. In PowerShell, the default shell on Windows runners, append to $env:GITHUB_OUTPUT instead ("value=1.4.2" >> $env:GITHUB_OUTPUT), or set shell: bash on the step.
  • Downstream steps read it with ${{ steps.<id>.outputs.<name> }}. In a script, pass it through env: as above rather than writing ${{ }} inside run:. The expression is pasted into the script before it runs, so quotes or untrusted text in the value can break the script or inject commands into it.
  • Since June 2026, a step can run with background: true. Its outputs reach later steps only after a wait or wait-all that includes it (see parallel steps).

This replaces the old echo "::set-output name=value::1.4.2" command, which is deprecated.

Multiline and structured values#

A single name=value line can’t hold a value that contains newlines — think a JSON document, a changelog, or multi-line command output. For those, GitHub Actions supports a heredoc-style delimiter syntax: write name<<DELIMITER, then the value, then the delimiter again on its own line.

.github/workflows/ci.yml
- name: Emit JSON output
id: meta
run: |
{
echo "json<<EOF"
cat data.json
echo "EOF"
} >> "$GITHUB_OUTPUT"

Here the whole block is grouped with { ... } >> "$GITHUB_OUTPUT" so every echo and the cat get appended to the file together. Pick a delimiter (EOF is conventional) that’s guaranteed not to appear inside the value — if you’re not sure, use a random string.

The closing delimiter must start its own line, so the value has to end with a newline. A file written by a program often doesn’t, and the step then fails with Matching delimiter not found. Use printf '%s\n' "$(cat data.json)" in place of cat data.json to add the newline, or, for JSON, skip the delimiter and compact it to one line: echo "json=$(jq -c . data.json)" >> "$GITHUB_OUTPUT".

Either way, you consume it like any other output, and parse it with fromJson if it’s JSON:

.github/workflows/ci.yml
- name: Read a field from the JSON
env:
NAME: ${{ fromJson(steps.meta.outputs.json).name }}
run: echo "$NAME"

Job outputs: passing data between jobs#

Step outputs live and die within a single job. To hand a value to a different job, you promote a step output to a job output using the job’s outputs: map, and the downstream job reads it through the needs context.

There are three requirements, and missing any one of them is the usual reason this “doesn’t work”:

  1. The producing step has an id and writes to $GITHUB_OUTPUT.
  2. The producing job declares an outputs: map that references that step output.
  3. The consuming job declares needs: <producing-job> — this both creates the dependency and makes needs.<job>.outputs available. Only direct dependencies count: a job further down the graph lists the producing job too (needs: [prepare, build]).

Here’s a complete two-job example:

.github/workflows/deploy.yml
name: Job outputs
on: push
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.value }}
steps:
- name: Compute a version
id: version
run: echo "value=1.4.2" >> "$GITHUB_OUTPUT"
deploy:
runs-on: ubuntu-latest
needs: prepare
steps:
- name: Deploy that version
env:
VERSION: ${{ needs.prepare.outputs.version }}
run: echo "Deploying $VERSION"

The deploy job won’t start until prepare succeeds, and it reads the value with ${{ needs.prepare.outputs.version }}. A common real-world use of this pattern is generating a dynamic matrix in one job and consuming it in another — covered in the matrix strategy article.

A step that uses an action exposes the action’s outputs the same way, as steps.<id>.outputs.<name>, so you can promote those too. A reusable workflow passes data back by mapping its job outputs to on.workflow_call.outputs, and the caller’s later jobs read them with needs.<calling-job>.outputs.<name>.

A masked value can’t be a job output. When a job output contains a secret or a value masked with add-mask, the runner skips it with the warning Skip output '<name>' since it may contain secret., and the next job reads an empty string. To pass a secret between jobs, keep it in a secret store and pass only a handle to it as the output, as in GitHub’s example ↗.

Outputs from a matrix job#

All the jobs of a matrix share one set of job outputs, so when several of them write the same output name, the last one to finish wins. To collect one value per matrix job, give each its own output name, or have each job upload a small artifact and merge them downstream:

.github/workflows/ci.yml
jobs:
test:
strategy:
matrix:
shard: [1, 2, 3]
runs-on: ubuntu-latest
steps:
- run: echo "shard ${{ matrix.shard }} ok" > "result-${{ matrix.shard }}.txt"
- uses: actions/upload-artifact@v7
with:
name: result-${{ matrix.shard }}
path: result-${{ matrix.shard }}.txt
report:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v8
with:
pattern: result-*
merge-multiple: true # all files in one directory
- run: cat result-*.txt

Job outputs have a size limit#

Job outputs are meant for small string data — version numbers, flags, JSON blobs, image tags. They are not a file-transfer channel. GitHub caps outputs at 1 MB per job and 50 MB total per workflow run (measured on UTF-16 encoding). If you try to pass a compiled artifact or a large dataset this way, you’ll hit those limits. For anything file-shaped or large, use artifacts instead.

$GITHUB_ENV: environment variables for later steps in the same job#

$GITHUB_OUTPUT is for values you address by name. $GITHUB_ENV is for values you want available as environment variables in every subsequent step of the same job. This is convenient when several later steps all need the same value and you’d rather not repeat a steps.<id>.outputs expression everywhere:

.github/workflows/ci.yml
steps:
- name: Set an env var
run: echo "BUILD_ID=$(date +%s)" >> "$GITHUB_ENV"
- name: Use it
run: echo "Build is $BUILD_ID"

The environment variables guide has the details in Setting a variable from a step: which steps see the variable, multi-line values and how to mask a value you computed.

Artifacts: passing files and large data between jobs#

When the thing you need to pass is a file — a compiled binary, a coverage report, a tarball, a built site — job outputs are the wrong tool. Upload it as an artifact in one job and download it in another. Artifacts handle binary data and have far larger limits than job outputs.

.github/workflows/deploy.yml
name: Build and deploy
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Build
run: |
mkdir -p dist
npm ci && npm run build
- name: Upload build output
uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v7
- name: Download build output
uses: actions/download-artifact@v8
with:
name: dist
path: dist/
- name: Deploy
run: ./deploy.sh dist/

Each job starts with an empty workspace, so deploy checks out the repository to get deploy.sh. The checkout comes first: actions/checkout empties a workspace that isn’t a Git repository, so it would delete files downloaded before it.

Artifacts are kept for 90 days by default, so they’re also how you make build outputs downloadable from the run’s summary page. The repository, organization or enterprise setting changes that period (1 to 90 days in public repositories, up to 400 in private ones), and retention-days on the upload sets a shorter one. In a private repository, retention-days: 1 on an artifact that only hands files to the next job limits how long it counts against your artifact storage. Since October 2026, the retention setting also deletes the workflow runs themselves, with their checks and commit statuses.

Things to know about the current artifact actions (v4 and later):

  • Names are unique per run and artifacts are immutable. Uploading to an existing name fails, unless you set overwrite: true. Matrix jobs need a name per job (dist-${{ matrix.os }}), then pattern to download them together. Without merge-multiple, each artifact lands in a directory named after it (dist-ubuntu-latest/, dist-windows-latest/). Use merge-multiple: true, as above, only when each job’s files have distinct names: files with the same name overwrite each other.
  • Single files without a zip. With upload-artifact v7, archive: false uploads one file as-is, so it downloads from the UI without being wrapped in a zip. The artifact takes the file’s name and name is ignored, so download it by the file name.
  • Executable bits are lost. A zipped artifact comes back with every file at mode 644, so a compiled binary is no longer executable. Run chmod +x after the download, or tar the files and upload the tarball with archive: false.
  • Downloads are checked. download-artifact v8 compares each downloaded artifact’s SHA-256 digest with the one recorded at upload and fails the step on a mismatch. Its digest-mismatch input (ignore, info, warn or error, the default) changes that.
  • Hidden files are skipped. Files and directories whose names start with a dot (.nojekyll, .htaccess, a .next/ build) are left out unless you set include-hidden-files: true.
  • From another run or workflow. download-artifact takes run-id and github-token (with actions: read) to fetch artifacts from a different run, which is how a workflow_run workflow gets the build’s output.
  • The job’s GITHUB_TOKEN isn’t needed for the same run. Within one run, upload and download need no extra permissions.

Choosing the right tool#

These mechanisms overlap a little, but each has a clear sweet spot:

NeedUseHow it travels
A value in later steps of the same job$GITHUB_ENVEnvironment variable, subsequent steps only
A named value in later steps of the same job$GITHUB_OUTPUT (step output)steps.<id>.outputs.<name>
Small string data between jobsJob outputs: + needsneeds.<job>.outputs.<name> (≤1 MB/job)
Files or large/binary data between jobsArtifactsupload-artifact → download-artifact
Data reused across separate runsCacheactions/cache, keyed restore

A rough decision flow: within a job, reach for $GITHUB_ENV or step outputs. Between jobs, use job outputs for a small string and artifacts for anything file-shaped or over the size limit. And if you want the same data to survive from one workflow run to the next — dependencies, build caches — that’s caching, covered in the caching article.

Conclusion#

Passing data in GitHub Actions comes down to matching the mechanism to the distance and shape of the data: $GITHUB_ENV and step outputs stay inside a job, job outputs carry small strings across the needs graph, artifacts move files between jobs, and caching carries data across runs. Stick to the environment-file syntax (>> "$GITHUB_OUTPUT" and >> "$GITHUB_ENV"), use the heredoc delimiter trick for multiline values, mask anything sensitive, and you’ll have clean, predictable data flow through even complex pipelines.