/changelogs/github-actions/set-output-to-github-output
GitHub Actions: from ::set-output and ::save-state to $GITHUB_OUTPUT
verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash) · 1.7.12updated 2026-10-20
- tool
- GitHub Actions
- versions
- ::set-output → $GITHUB_OUTPUT
Workflow commands printed to standard output (::set-output, ::save-state) let any program in a step, including a dependency that echoes untrusted text, set outputs. GitHub deprecated them in October 2022 in favour of environment files: the runner exposes a file path in $GITHUB_OUTPUT, and you append name=value lines to it.
Before and after
# before (deprecated)
- id: meta
run: echo "::set-output name=version::1.4.0"
# after
- id: meta
run: echo "version=1.4.0" >> "$GITHUB_OUTPUT"
- run: echo "${{ steps.meta.outputs.version }}"actionlint flags the old command
mkdir -p .github/workflows
cat > .github/workflows/ci.yml <<'EOF'
name: CI
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- id: meta
run: |
echo "::set-output name=version::1.4.0"
echo "::save-state name=pid::1234"
- run: echo "${{ steps.meta.outputs.version }}"
EOF
actionlint -no-color .github/workflows/ci.ymlOutput · exit 1
.github/workflows/ci.yml:8:14: workflow command "save-state" was deprecated. use `echo "{name}={value}" >> $GITHUB_STATE` instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions [deprecated-commands]
|
8 | run: |
| ^
.github/workflows/ci.yml:8:14: workflow command "set-output" was deprecated. use `echo "{name}={value}" >> $GITHUB_OUTPUT` instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions [deprecated-commands]
|
8 | run: |
| ^Multiline values
Use a delimiter, as with heredocs:
{
echo "changelog<<EOF"
git log --oneline -5
echo "EOF"
} >> "$GITHUB_OUTPUT"All environment files
| Old command | Replacement |
|---|---|
| ::set-output name=N::V | echo "N=V" >> "$GITHUB_OUTPUT" |
| ::save-state name=N::V | echo "N=V" >> "$GITHUB_STATE" (read as $STATE_N in post steps) |
| ::set-env name=N::V | echo "N=V" >> "$GITHUB_ENV" |
| ::add-path::DIR | echo "DIR" >> "$GITHUB_PATH" |
In PowerShell steps: "version=1.4.0" >> $env:GITHUB_OUTPUT.
Sources
- github.bloggithub.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
- docs.github.comdocs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-output-parameter
- docs.github.comdocs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#multiline-strings
Related pages
commands · github-actionsactionlint: lint GitHub Actions workflows before you pushactionlint checks .github/workflows files for syntax errors, bad expressions, untrusted input in run scripts, deprecated commands and outdated actions.cheat sheets · github-actionsGitHub Actions cheat sheet: triggers, jobs, matrix, outputs and cachingGitHub Actions cheat sheet: triggers, jobs and needs, matrix builds, if conditions, step and job outputs, secrets and env, caching, artifacts, contexts.flags · github-actionsGitHub Actions shell: bash vs the default: -e and pipefailWithout shell:, Linux run steps use bash -e and miss failures inside pipelines. shell: bash runs bash --noprofile --norc -eo pipefail and catches them.