If you have a GitHub Actions workflow that sets an output using
echo ::set-output key=value, you have started to see an unhelpful deprecation warning. Here’s how to fix it.
If you use the old way, you’ll get annotations like the following one in your workflow run summaries:
set-outputcommand is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information, see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
Unfortunately, the linked blog post is super unhelpful:
Action and workflow authors who are using save-state or set-output via stdout should update to use the new environment files.
Deprecating a feature with a threat of breaking soon and vaguely waving at general documentation is one of my least favorite things in software development. If a volunteer-run FOSS project does that, it’s not great. If virtually-unlimited-money Microsoft does it, it’s an arrogant power move.
I suspect it’s born from people working on features thinking that all their users are intimate with said features all the time. But in my experience, FOSS developers set up their CIs and don’t touch them until they break.
Many won’t see the warning until it breaks and even more will be confused.
Anyhow, if you have lines like these in your workflow:
run: echo "::set-output name=KEY::VALUE"
Change them into:
run: echo "KEY=VALUE" >>$GITHUB_OUTPUT
Do better GitHub – I’m sure you would’ve found space for this in your blog post.
Update 2022-10-19: they did find the space and the article is much better now!