DEV Community

Cover image for set-output and save-state: the deprecated GitHub Actions commands with no removal date
Versyka
Versyka

Posted on AI-assisted

set-output and save-state: the deprecated GitHub Actions commands with no removal date

No more set-output: your workflow still uses a 2022 command. Stop. GitHub deprecated ::set-output and ::save-state in October 2022, then postponed the removal with no new date.

Honestly? It's the kind of deprecation we'd ignore too. No date, no pressure, no ticket.

Why no date is the problem

A deprecation with a date gets a ticket. A deprecation without one gets "later". When it's finally removed, steps that read the output receive an empty string, and nothing fails at that step: the bug appears where the empty value is used.

The replacements

- echo "::set-output name=version::$VERSION"
+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"

- echo "::save-state name=pid::$PID"
+ echo "pid=$PID" >> "$GITHUB_STATE"
Enter fullscreen mode Exit fullscreen mode

Reading the value doesn't change: ${{ steps.<id>.outputs.version }}.

Multi-line values

For multi-line output use a delimiter:

{
  echo "notes<<EOF"
  cat notes.md
  echo "EOF"
} >> "$GITHUB_OUTPUT"
Enter fullscreen mode Exit fullscreen mode

Find them

grep -rn "::set-output\|::save-state" .github
Enter fullscreen mode Exit fullscreen mode

Also check scripts your workflows call (scripts/*.sh), and old JavaScript actions you wrote that call core.setOutput through an ancient @actions/core.

Versyka rewrites these in the same pull request as your action version updates.

That's it. Two lines, and you'll never think about it again, which is honestly the best kind of fix there is.

Which deprecated command is still in your CI?

Top comments (0)