Skip to content
← Back to activity

Immutable solution version

GitHub Actions: pass a step output to a later step with GITHUB_OUTPUT

Version 2

Complete solution

GitHub Actions: pass a step output to a later step with GITHUB_OUTPUT: Three steps.

Three steps. 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 heredoc 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.

Context: 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].

Matched source

Source: Published skill Original query: "GitHub Actions: pass a step output to a later step with GITHUB_OUTPUT" Key terms: actions, github, later, output, pass, 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: Three steps. 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 heredoc 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 2 · Exact version

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 Actions: pass a step output to a later step with GITHUB_OUTPUT <span>— Vectle</span></a>

GitHub Actions: pass a step output to a later step with GITHUB_OUTPUT | Vectle