1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【github actions】workflow dispatchでbranchのファイルを更新する処理の後、call workflowするときの注意点

1
Last updated at Posted at 2026-03-02

TL;DR

workflow dispatchを使う場合、call-workflowの先のコードで、with ref: ${{ github.ref_name }} で明確に指定しないとworkflow dispatch起動したタイミングのSHAが使われちゃう。

バグを探る

  • あまり使われていないっぽいgithubactionsを手順通り使って何かうまくいっていない
    • READMEの記載も曖昧な部分がありそう
    • バグがありそう
    • workflow dispatchでgithub actionsを起動。github actionsでブランチのファイルの更新がされる。その先のcall-workflowで次の処理があるが、それが正しくできていなさそう。
    • github actions上からはcall-workflowもその後の処理も成功している。

結論

call-workflowの先で、
workflow dispatch実行時のSHAが使われていた。
workflow dispatch実行時に指定した時点のSHAなので、githubactionsにより自動ファイル更新が行われる前のものが、call-workflowの先で使われてしまった。

修正

checkout repositoryの部分を次のように修正。

      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          ref: ${{ github.ref_name }}

テストして、無事、更新後のSHAが使われるようになった。
マージされたあと、cherry-pickして無事トピックブランチでもテストできるようになった。

公式ドキュメント

ワークフローを再利用する
https://docs.github.com/ja/actions/how-tos/reuse-automations/reuse-workflows

If you use the second syntax option (without {owner}/{repo} and @{ref}) the called workflow is from the same commit as the caller workflow. Ref prefixes such as refs/heads and refs/tags are not allowed. You cannot use contexts or expressions in this keyword.

学び

  • READMEが正しくない時など手順が不明なときは、どの前提が必要かを把握して、その前提ができているかを確認してから進めると良さそう
    • 手順を回して、手順に足りていない部分がある、を気づいてやり直すと無駄に時間を溶かしてしまうかも。

以上

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?