Skip to content

GitHubでGCP Vertex AIを使ったClaude Code Actionをセットアップする

手元でClaude Codeをセットアップする手順はGCP Vertex AIを使ったClaude Codeのセットアップに書いた。

GitHubと連携させる設定は公式ドキュメントにある。

ただし /install-github-app が使えるのはAnthoropicアカウントに限定されているので、GCP Vertex AIを使う場合は下の方にある「AWS BedrockおよびGoogle Vertex AIでの使用」の手順を踏む必要がある。

GCP Workload Identityを利用する。設定するときにWorkload Identityの属性条件式を使って、Claude Code Actionを追加するリポジトリを許可しておく必要がある。

設定が完了したら以下の値をGitHubのシークレットとして登録するが、たぶん見えても困らないと思う。

  • GCP_WORKLOAD_IDENTITY_PROVIDER
  • GCP_SERVICE_ACCOUNT

後者はWorkload Identityプールに設定したサービスアカウントのメールアドレスがそのまま利用される。前者は以下のような形式の文字列で、GCPコンソールからコピーする手段が見つからなかったので自分で組み立てる。

projects/<project-id>/locations/global/workloadIdentityPools/<pool-name>/providers/<provider-name>

以上の準備ができたら、公式ドキュメントにあるワークフローファイルをコピーすればいい。2025年時点のサンプルを置いておくが、そのうち古くなる。

name: Claude Assistant
permissions:
contents: write
pull-requests: write
issues: write
id-token: write
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]
jobs:
claude-pr:
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'issues' && contains(github.event.issue.body, '@claude')) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude'))
runs-on: utuntu-latest
steps:
- uses: actions/checkout@v4
- uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
id: auth
- uses: anthropics/claude-code-action@v0.0.13
with:
timeout_minutes: 30
use_vertex: "true"
allowed_tools: >+
Bash(npm:*),
Bash(go:*),
env:
ANTHROPIC_VERTEX_PROJECT_ID: ${{ steps.auth.outputs.project_id }}
CLOUD_ML_REGION: us-east5