Immutable solution version
github_output: pass a step output to a later step with $GITHUB_OUTPUT in GitHub Actions
Complete solution
github_output is the file each GitHub Actions step uses to pass outputs to later steps: give the producing step an id, append name=value lines to $GITHUB_OUTPUT, and read them back as steps outputs. Covers empty outputs, multiline values, and the removed set-output command. Not for job outputs across jobs (needs outputs plus needs), artifacts, or environment variables (that is $GITHUB_ENV).
When it applies
Not specified by the original author.
Instructions
TL;DR
github_output is the mechanism GitHub Actions gives a step for passing values to later steps in the same job. Give the producing step an id, append a line like echo "result=value" >> "$GITHUB_OUTPUT" inside its run script, and read the value back in later steps as ${{ steps.[id].outputs.result }} (write your step id in place of [id]). Outputs set any other way, including the old set-output command, do not arrive.
- id: gen
run: echo "result=hello" >> "$GITHUB_OUTPUT"
- run: echo "got ${{ steps.gen.outputs.result }}"Expected output: the second step prints got hello.
Use this when
- A later step, summary, or Slack notification needs a value an earlier step computed
- Your workflow writes to GITHUB_OUTPUT but the consuming step sees an empty string
- You are migrating off the deprecated set-output workflow command
- A composite action or reusable workflow needs to expose a value it computed
Not for this skill when
- The value must cross into a different job (use job outputs with
outputs:on the producing job andneedson the consumer) - The value is a file (use upload-artifact / download-artifact instead)
- Every later step should see the value as an environment variable (that is $GITHUBENV, not $GITHUBOUTPUT)
- The output comes from a Docker container action (declare it in the action metadata instead)
Steps
- Give the producing step an id. Outputs are addressed through the step id, so a step with no id cannot be read back:
- id: gen
run: echo "the value is computed here"Expected: the workflow parses; the id is unique within the job.
- In that same step, append name=value lines to the file named by $GITHUB_OUTPUT:
echo "result=$(my-command)" >> "$GITHUB_OUTPUT"
echo "count=3" >> "$GITHUB_OUTPUT"Expected: the step exits 0. Each line becomes one named output. Writing to a file you create yourself, or echoing without the redirect, does nothing.
- Read the outputs in any later step of the same job:
- run: echo "result was ${{ steps.gen.outputs.result }}"Expected: the value from step 2 prints. A step cannot read its own outputs, and outputs are strings, so convert numbers and booleans yourself.
- For multiline values, use the delimiter form: the first line written is the output name, then two left angle brackets (written as << in this page so the example survives formatting), then a delimiter word of your choice; then the value lines; then the delimiter word again on its own line. Pick a delimiter that cannot appear inside the value.
Expected: the consuming step receives the full multiline string, newlines included. Without the delimiter form, only the first line survives and the rest are parsed as more outputs.
- If the output arrives empty, debug in this order: the producing and consuming steps are in the same job; the id matches exactly, including case; the write happened in the step that declares the id; you appended to "$GITHUB_OUTPUT" (quoted, with the dollar sign) instead of printing to stdout.
Expected: one of the four mismatches is the cause in almost every empty-output report.
Variant phrasings
github_output not working in github actions
Almost always step 5 above: wrong job, mismatched id, or the removed set-output command silently doing nothing. See the related skill below for the set-output migration in detail.
GITHUBOUTPUT vs GITHUBENV vs GITHUB_PATH
GITHUBOUTPUT passes a named value to steps that ask for it by id. GITHUBENV sets an environment variable for all later steps. GITHUB_PATH prepends a directory to PATH for later steps. Picking the wrong file is a common reason a value seems to vanish.
Passing an output from a composite action
Inside the composite action, write to $GITHUB_OUTPUT the same way, and declare the output in the action.yml outputs section mapping it to the inner step. Without the declaration, the caller sees nothing.
Why it happens
Early workflows passed values with a stdout workflow command, set-output, which GitHub deprecated for security reasons (any step output could inject commands into later steps) and then disabled. The file-based GITHUB_OUTPUT mechanism replaced it: the runner watches the file, parses name=value lines after the step ends, and exposes them under the step id. That design is why the id, the same-job rule, and the append-to-the-file rule are all non-negotiable.
Edge cases
- Windows runners with PowerShell: the file is at $env:GITHUB_OUTPUT and you append with Out-File -Append or the same echo redirect in pwsh; bash syntax does not carry over unchanged.
- Values containing equals signs are fine after the first one: only the first equals splits name from value.
- Very large outputs hit runner limits; write big payloads to an artifact and pass the artifact name as the output instead.
Tool compatibility
GitHub Actions on GitHub-hosted and self-hosted runners, all shells. The set-output command was disabled in 2023, so any workflow still using it needs this file-based form.
Related skills
- githuboutput not working in github actions: https://vectle.com/skills/sklDOBm6hYkPUqcyOnN-42BCQ
- github actions: Unable to process file command output (set-output removed): https://vectle.com/skills/skl_J5SAbaYiE-dL5kquHdVcZQ
- Unable to process file command 'output' successfully in GitHub Actions: https://vectle.com/skills/skl9FIiJRezotJcRvd7VTPhQ
Provenance
Resolved from Stack Overflow question 59191913 (accepted answer): a workflow needed the output of one step in a later notification step.
Evidence
Source: Stack Overflow #59191913 (accepted answer, 145 votes): a workflow needs the output of the Run tests step in a later Slack notification step, and the asker does not know the mechanism. The accepted answer lays out the three-part pattern: give the producing step an id, write name=value lines to the GITHUB_OUTPUT file, and read them back as steps.[id].outputs.[name].
Verified resolution: First, add an id to the producing step. Second, inside its run script, append lines like echo "result=$(my-command)" >> $GITHUB_OUTPUT (multiline values need the delimiter form). Third, consume it later as ${{ steps.[id].outputs.result }}. Do not use the old set-output command; it is deprecated and disabled. Outputs must be set in the same step that declares the id, and a step cannot read its own outputs.
Source URL: https://stackoverflow.com/questions/59191913/how-do-i-get-the-output-of-a-specific-step-in-github-actions
By @issueatlas · Version 4 · Exact version
Maintainer review
Checking maintainer review for this exact version…
A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_3-Qp4cNCE362i3aespgQdA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">github_output: pass a step output to a later step with $GITHUB_OUTPUT in GitHub Actions <span>— Vectle</span></a>