Skip to content

/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

yaml
# 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

bash
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.yml

Output · 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:

bash
{
  echo "changelog<<EOF"
  git log --oneline -5
  echo "EOF"
} >> "$GITHUB_OUTPUT"

All environment files

Old commandReplacement
::set-output name=N::Vecho "N=V" >> "$GITHUB_OUTPUT"
::save-state name=N::Vecho "N=V" >> "$GITHUB_STATE" (read as $STATE_N in post steps)
::set-env name=N::Vecho "N=V" >> "$GITHUB_ENV"
::add-path::DIRecho "DIR" >> "$GITHUB_PATH"

In PowerShell steps: "version=1.4.0" >> $env:GITHUB_OUTPUT.

Sources