0
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でreuseful workflowを作る上での注意点

Last updated at Posted at 2025-07-15

GitHub Actionsにはreuseful workflowと呼ばれる集中Pipelineを作る機能が存在する。

Devinを用いて作らせていたのだが、見事なまでにDevin君がハマっていたので、以下備忘録的に。

PublicリポジトリからPrivateリポジトリのworkflowは呼び出せない。

ここにも書いてはあるんだけど。要するにreuseful workflowをPrivateとして作成していた場合は、Publicからは呼び出せない。Privateリポジトリオンリー。
https://zenn.dev/kou_pg_0131/articles/gh-actions-share-private
このサイトの上部にある設定の問題かと思ったら違った。

一番下に Access というセクションがあります。
Accessible from repositories owned by the user '<ユーザー名>' を選択し、 Save をクリックして設定を保存します。

とはいえこれはやっておくと良いはず。

reuseful側の相対パスを絶対パスに変更する必要がある。

相対パス呼び出しを絶対パス形式に変更: uses: ./.github/workflows/common-init.yaml@uses: xxxxxxxxxx/sample001/.github/workflows/common-init.yaml@main に変更

Devin君は自己解決してたけど。
全ての内部ワークフロー呼び出しを修正する必要があるが、横展開は生成AIにお任せ。

ジョブの呼び出し方をjobs.*.usesを利用する必要がある。

呼び出し元、呼び出し側いずれもだが、jobs.ci.usesを利用する必要がある。
つまりreuseful側でstep levelでワークフロー呼び出しをしている箇所があるとダメ。
「reusable workflows should be referenced at the top-level `jobs.*.uses' key, not within steps」こんなエラーがPipeline側に出てるのでそれで判別。Devin君はActionsのエラーログをなぜかみてくれなかったが...

jobs:
  init:
    runs-on: ubuntu-latest
    outputs:
      ENV_TYPE: ${{ steps.init.outputs.ENV_TYPE }}
      ENVIRONMENT: ${{ steps.init.outputs.ENVIRONMENT }}
      CONFIG_FILES: ${{ steps.init.outputs.CONFIG_FILES }}
    steps:
      - name: Call common init workflow
        id: init
        uses: xxxxxxxxx/sample001/.github/workflows/common-init.yaml@main
        with:
          REPO_TYPE: ${{ inputs.REPO_TYPE }}
          ENV: ${{ inputs.ENV }}
          CONFIG_FILES: ${{ inputs.CONFIG_FILES }}

こんな書き方ではダメで

    uses: xxxxxxxxx/sample001/.github/workflows/common-init.yaml@main
    with:
      REPO_TYPE: ${{ inputs.REPO_TYPE }}
      ENV: ${{ inputs.ENV }}
      CONFIG_FILES: ${{ inputs.CONFIG_FILES }}

こんな書き方にする必要がある。

その他

これはreuseful固有事象とは異なると思うのだけど、非推奨Actionを利用しているとうまく動かなかった。

Deprecated actions: Updated actions/cache@v3 and actions/upload-artifact@v3 to v4 versions

とはいえ、

CIは作ったけどCDはまだこれからなんだけどな!
あとDevinの話をかけよというような気もするが、それはまたどこかで。

0
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
0
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?