できない.dev

GitHub Actions の set-output deprecation 警告が消えない

set-output の deprecation 警告は、$GITHUB_OUTPUT への追記に書き換えれば消える。
自前のステップのほか、古い actions/cache@v2 などに残っていることも多い。

公開: 更新:

症状できない
echo "::set-output name=value::from-set-output"
##[warning]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/

2026-09-22 に github-actions-runner (ubuntu-latest)(Runner 2.337.0 / Runner Image ubuntu-24.04 20260907.300.1) で実際に打って取った出力。検証環境の詳細

要約

Warning: The set-output command is deprecated が出続ける場合は、(1) 自前 shell ステップ、(2) 古い action のバージョン、(3) composite action / reusable workflow、のいずれかに ::set-output 形式が残っている。
公式 workflow commands(新しいタブで開く) のとおり $GITHUB_OUTPUT への append に置き換える。

実行例

GitHub の ubuntu-latest ランナー(Runner 2.337.0)で ::set-output を echo すると、そのステップに警告が付いた。
警告の文面は「The set-output command is deprecated and will be disabled soon.」である。
値自体はまだ従来どおり outputs に渡り、後続ステップでは old=[from-set-output] と表示された。
$GITHUB_OUTPUT へ追記する書き方では警告は出ず、同じように new=[from-github-output] が受け取れた。

$ echo "::set-output name=value::from-set-output"
##[warning]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/
$ echo "value=from-github-output" >> "$GITHUB_OUTPUT"
$ echo "old=[${{ steps.old.outputs.value }}]"
old=[from-set-output]
$ echo "new=[${{ steps.new.outputs.value }}]"
new=[from-github-output]

— 2026-09-22 時点の出力

検証環境Runner 2.337.0 / Runner Image ubuntu-24.04 20260907.300.1 / 2026-09-22 検証
検証日
実行環境
github-actions-runner (ubuntu-latest) Ubuntu 24.04.5 LTS
バージョン
  • Runner 2.337.0
  • Runner Image ubuntu-24.04 20260907.300.1

この記事の「実行例」は、上記の環境で実際にコマンドを実行して得られた出力をそのまま掲載しています。 再現手順はリポジトリの検証スクリプトとして管理し、定期的に再実行して出力を更新しています。

解決策

1. 自前ステップを書き換える

- id: vars
  run: |
    echo "version=$(cat VERSION)" >> "$GITHUB_OUTPUT"
- run: echo "got ${{ steps.vars.outputs.version }}"

複数行を渡すときは heredoc 形式を使う。

- id: notes
  run: |
    {
      echo "notes<<EOF"
      cat CHANGELOG.md
      echo "EOF"
    } >> "$GITHUB_OUTPUT"

2. action のバージョンを上げる

2022-10-11 のチェンジログ(新しいタブで開く) 以降にリリースされたメジャーでは内部で $GITHUB_OUTPUT に切り替わっている。

- uses: actions/checkout@v4
- uses: actions/cache@v4
- uses: actions/upload-artifact@v4

3. composite action 内も置換

自社製 composite action の action.yml 内の steps にも同じ書き換えを適用する。
steps の書式は、metadata syntax ドキュメント(新しいタブで開く) の runs.steps に載っている。

4. save-state も合わせて置換

post 処理用の ::save-state は、$GITHUB_STATE への append に置き換える。

- run: echo "pid=$$" >> "$GITHUB_STATE"

よくある原因

  1. 自前のステップに旧書式が残っている。
    echo "::set-output name=foo::$VAL" をそのまま使っている。
  2. action のバージョンが古い。
    actions/cache@v2 など、内部に旧コマンドを含むものを使っている。
  3. composite action の中に旧書式がある。
    自社製 action の action.yml の steps に残っている。
  4. ::save-state も同時に deprecation になっている。
    ポスト処理用の状態保存も、同じく置き換える必要がある。