Skip to content

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.

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.
Form options