GitHub Actions: The `set-output` command is deprecated and will be disabled soon
If you use GitHub Actions to run Workflows and tests, you might have spotted this warning recently:
The `set-output` command 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/
This warning means that GitHub will deprecate a certain syntax which populates variables, and disables it by end of May 2023.
How does this syntax look like? Let me show one example:
- name: Store LXD version
run: echo "::set-output name=LXD_Version::$(lxd --version)"
id: lxd_version
This is from the Ansible lxc-ssh connection plugin, which allows to use regular ssh connections to manage LXC container in Ubuntu.
The tests for this plugin spin up an Ubuntu instance, and then a container inside and test the connectivity and functionality for the plugin. Among other challenges, the test workflow needs to decide which commands to run, based on the LXC version. Above code stores the version in the variable $LXD_Version. This is the old, and deprecated syntax, using ::set-output.
GitHub explains how to change the code, and use the new syntax. Unfortunately the description is a bit ambigous, as it mixes "name" and "name" (yes, that's both "name" for you).
- name: Set output
run: echo "::set-output name={name}::{value}"
- name: Set output
run: echo "{name}={value}" >> $GITHUB_OUTPUT
Let me change this example, to make it more obvious what needs to be updated:
- name: Set output
run: echo "::set-output name=varname::varvalue"
- name: Set output
run: echo "varname=varvalue" >> $GITHUB_OUTPUT
The "name=varname" is removed, in the new syntax it's "varname=varvalue". The above example, in the new syntax, is:
- name: Store LXD version
run: echo "LXD_Version=$(lxd --version)" >> $GITHUB_OUTPUT
id: lxd_version
Everytime I update one of the workflows I first completely miss the part that the old syntax has a superfluous "name=" in it. After a couple seconds I remember again, and remove this part.
Comments
Display comments as Linear | Threaded