🤖
同じGoogle CloudプロジェクトのVertex AIから複数リポジトリでClaude Code Actionを使う方法
はじめに
同じGoogle CloudプロジェクトのVertex AIから複数リポジトリでClaude Code Actionを使う時に結構つまづいたので記事にしました。
一つのリポジトリでClaude Code Actionを使うときは↓の記事がとてもわかりやすく参考になります。
今回は、この記事の内容を補足する形で、複数リポジトリで使う時に必要な作業を記します。
必要な作業
以下、repo_1の他にrepo_2というリポジトリを追加するという設定で書いていきます。
リポジトリ側の設定
GitHub Appsは同じものを使いまわせるので追加の設定は不要です。
repo_2 の Settings > Secrets and variables > Actions に移動し、Repository secrets に以下の変数を設定します。この設定はリポジトリごとに必要ですが、変数の値はリポジトリが違っても完全に同じです。
- APP_ID:
- APP_PRIVATE_KEY:
- GCP_SERVICE_ACCOUNT
- GCP_WORKLOAD_IDENTITY_PROVIDER
GCP Workload Identity Pool の設定
リポジトリを追加するたびに、プロバイダを編集する
編集先
プロバイダの編集画面の属性条件に新しいリポジトリを追加します。
編集イメージ:repo_2の分をor条件でつなぎます。
assertion.repository == "your-organization/repo_1" || assertion.repository == "your-organization/repo_2"
Workload Identity User権限を付与
ここの作業は少し調べた感じCLIでしかできなかったので、gcloudコマンドで実行しています。
repo_2に対して追加で付与するコマンド例です。
gcloud iam service-accounts add-iam-policy-binding \
<your-service-account>@<your-project-id>.iam.gserviceaccount.com \
--role roles/iam.workloadIdentityUser \
--member "principal://iam.googleapis.com/projects/<your-project-number>/locations/global/workloadIdentityPools/<your-identity-pool-id>/subject/<your-organization>/repo_2"
Workload Identity Userバインディングを確認
gcloud iam service-accounts get-iam-policy <your-service-account>@<your-project-id>.iam.gserviceaccount.com
期待される出力例:
bindings:
- members:
- principal://iam.googleapis.com/projects/<your-project-number>/locations/global/workloadIdentityPools/<your-identity-pool-id>/subject/<your-organization>/repo_1
role: roles/iam.workloadIdentityUser
- principal://iam.googleapis.com/projects/<your-project-number>/locations/global/workloadIdentityPools/<your-identity-pool-id>/subject/<your-organization>/repo_2
role: roles/iam.workloadIdentityUser
おわりに
これで、同じGoogle CloudプロジェクトのVertex AIから複数リポジトリでClaude Code Actionが使えるはずです!
Discussion