Claude Code GitHub Actionsを開発ワークフローに統合する方法について学びます
@claudeと言及するだけで、Claudeはコードを分析し、プルリクエストを作成し、機能を実装し、バグを修正できます。すべてプロジェクトの標準に従いながら。CLAUDE.mdガイドラインと既存のコードパターンを尊重します/install-github-appを実行するだけです。このコマンドは、GitHubアプリと必要なシークレットのセットアップをガイドします。/install-github-appコマンドが失敗した場合、または手動セットアップを希望する場合は、以下の手動セットアップ手順に従ってください:.github/workflows/へ@claudeをタグ付けしてアクションをテストしてください!@betaを@v1に変更mode: "tag"またはmode: "agent"を削除(現在は自動検出)direct_promptをpromptに置き換えmax_turns、model、custom_instructionsなどをclaude_argsに変換| 古いベータ入力 | 新しいv1.0入力 |
|---|---|
mode | (削除 - 自動検出) |
direct_prompt | prompt |
override_prompt | prompt(GitHubの変数付き) |
custom_instructions | claude_args: --system-prompt |
max_turns | claude_args: --max-turns |
model | claude_args: --model |
allowed_tools | claude_args: --allowedTools |
disallowed_tools | claude_args: --disallowedTools |
claude_env | settings JSON形式 |
-uses:anthropics/claude-code-action@beta with: mode:"tag" direct_prompt:"Review this PR for security issues" anthropic_api_key:${{ secrets.ANTHROPIC_API_KEY }} custom_instructions:"Follow our coding standards" max_turns:"10" model:"claude-sonnet-4-5-20250929"-uses:anthropics/claude-code-action@v1 with: prompt:"Review this PR for security issues" anthropic_api_key:${{ secrets.ANTHROPIC_API_KEY }} claude_args:| --system-prompt "Follow our coding standards" --max-turns 10 --model claude-sonnet-4-5-20250929@claudeメンションに応答)または自動化モード(プロンプト付きで即座に実行)で実行するかどうかを自動的に検出します。name:Claude Codeon: issue_comment: types: [created] pull_request_review_comment: types: [created]jobs: claude: runs-on:ubuntu-latest steps: -uses:anthropics/claude-code-action@v1 with: anthropic_api_key:${{ secrets.ANTHROPIC_API_KEY }} # Responds to @claude mentions in commentsname:Code Reviewon: pull_request: types: [opened,synchronize]jobs: review: runs-on:ubuntu-latest steps: -uses:anthropics/claude-code-action@v1 with: anthropic_api_key:${{ secrets.ANTHROPIC_API_KEY }} prompt:"/review" claude_args:"--max-turns 5"name:Daily Reporton: schedule: -cron:"0 9 * * *"jobs: report: runs-on:ubuntu-latest steps: -uses:anthropics/claude-code-action@v1 with: anthropic_api_key:${{ secrets.ANTHROPIC_API_KEY }} prompt:"Generate a summary of yesterday's commits and open issues" claude_args:"--model claude-opus-4-1-20250805"@claude implement this feature based on the issue description@claude how should I implement user authentication for this endpoint?@claude fix the TypeError in the user dashboard componentCLAUDE.mdファイルを作成して、コードスタイルガイドライン、レビュー基準、プロジェクト固有のルール、および推奨パターンを定義します。このファイルは、Claudeのプロジェクト標準の理解をガイドします。ANTHROPIC_API_KEYという名前のリポジトリシークレットとして追加anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}${{ secrets.ANTHROPIC_API_KEY }})を使用してください。CLAUDE.mdを簡潔で焦点を絞ったものに保ち、ワークフローに適切なタイムアウトを設定します。@claudeコマンドを使用して、不要なAPI呼び出しを減らしますclaude_argsで適切な--max-turnsを設定して、過度な反復を防ぎます-uses:anthropics/claude-code-action@v1 with: anthropic_api_key:${{ secrets.ANTHROPIC_API_KEY }} prompt:"Your instructions here" # Optional claude_args:"--max-turns 5" # Optional CLI argumentspromptを使用/reviewや/fixなどの事前構築されたプロンプトclaude_args経由のClaude Code CLIの任意の引数promptパラメータを使用して指示を提供します。カスタムGitHubアプリを作成(3Pプロバイダーに推奨)
.pemファイルを保存.pemファイルの内容を含むAPP_PRIVATE_KEYという名前の新しいシークレットを作成APP_IDという名前の新しいシークレットを作成クラウドプロバイダー認証を設定
AWS Bedrock
セキュリティに関する注意: リポジトリ固有の設定を使用し、最小限の必要な権限のみを付与します。必要なセットアップ:
https://token.actions.githubusercontent.comsts.amazonaws.comtoken.actions.githubusercontent.comAmazonBedrockFullAccessポリシーGoogle Vertex AI
セキュリティに関する注意: リポジトリ固有の設定を使用し、最小限の必要な権限のみを付与します。必要なセットアップ:
https://token.actions.githubusercontent.comVertex AI Userロールのみを付与必要なシークレットを追加
ANTHROPIC_API_KEY:console.anthropic.comからのClaude APIキーAPP_ID: GitHubアプリのIDAPP_PRIVATE_KEY: プライベートキー(.pem)の内容GCP_WORKLOAD_IDENTITY_PROVIDERGCP_SERVICE_ACCOUNTAPP_ID: GitHubアプリのIDAPP_PRIVATE_KEY: プライベートキー(.pem)の内容AWS_ROLE_TO_ASSUMEAPP_ID: GitHubアプリのIDAPP_PRIVATE_KEY: プライベートキー(.pem)の内容ワークフローファイルを作成
AWS Bedrockワークフロー
| シークレット名 | 説明 |
|---|---|
AWS_ROLE_TO_ASSUME | Bedrockアクセス用のIAMロールのARN |
APP_ID | GitHubアプリID(アプリ設定から) |
APP_PRIVATE_KEY | GitHubアプリ用に生成したプライベートキー |
name:Claude PR Actionpermissions: contents:write pull-requests:write issues:write id-token:writeon: issue_comment: types: [created] pull_request_review_comment: types: [created] issues: types: [opened,assigned]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')) runs-on:ubuntu-latest env: AWS_REGION:us-west-2 steps: -name:Checkout repository uses:actions/checkout@v4 -name:Generate GitHub App token id:app-token uses:actions/create-github-app-token@v2 with: app-id:${{ secrets.APP_ID }} private-key:${{ secrets.APP_PRIVATE_KEY }} -name:Configure AWS Credentials (OIDC) uses:aws-actions/configure-aws-credentials@v4 with: role-to-assume:${{ secrets.AWS_ROLE_TO_ASSUME }} aws-region:us-west-2 -uses:anthropics/claude-code-action@v1 with: github_token:${{ steps.app-token.outputs.token }} use_bedrock:"true" claude_args:'--model us.anthropic.claude-sonnet-4-5-20250929-v1:0 --max-turns 10'us.anthropic.claude...)とバージョンサフィックスが含まれます。Google Vertex AIワークフロー
| シークレット名 | 説明 |
|---|---|
GCP_WORKLOAD_IDENTITY_PROVIDER | Workload identity providerリソース名 |
GCP_SERVICE_ACCOUNT | Vertex AIアクセス権を持つサービスアカウントメール |
APP_ID | GitHubアプリID(アプリ設定から) |
APP_PRIVATE_KEY | GitHubアプリ用に生成したプライベートキー |
name:Claude PR Actionpermissions: contents:write pull-requests:write issues:write id-token:writeon: issue_comment: types: [created] pull_request_review_comment: types: [created] issues: types: [opened,assigned]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')) runs-on:ubuntu-latest steps: -name:Checkout repository uses:actions/checkout@v4 -name:Generate GitHub App token id:app-token uses:actions/create-github-app-token@v2 with: app-id:${{ secrets.APP_ID }} private-key:${{ secrets.APP_PRIVATE_KEY }} -name:Authenticate to Google Cloud id:auth uses:google-github-actions/auth@v2 with: workload_identity_provider:${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} service_account:${{ secrets.GCP_SERVICE_ACCOUNT }} -uses:anthropics/claude-code-action@v1 with: github_token:${{ steps.app-token.outputs.token }} trigger_phrase:"@claude" use_vertex:"true" claude_args:'--model claude-sonnet-4@20250514 --max-turns 10' env: ANTHROPIC_VERTEX_PROJECT_ID:${{ steps.auth.outputs.project_id }} CLOUD_ML_REGION:us-east5 VERTEX_REGION_CLAUDE_3_7_SONNET:us-east5@claudeが含まれていることを確認します(/claudeではなく)。| パラメータ | 説明 | 必須 |
|---|---|---|
prompt | Claude用の指示(テキストまたはスラッシュコマンド) | いいえ* |
claude_args | Claude Codeに渡されるCLI引数 | いいえ |
anthropic_api_key | Claude APIキー | はい** |
github_token | API アクセス用のGitHubトークン | いいえ |
trigger_phrase | カスタムトリガーフレーズ(デフォルト:「@claude」) | いいえ |
use_bedrock | Claude APIの代わりにAWS Bedrockを使用 | いいえ |
use_vertex | Claude APIの代わりにGoogle Vertex AIを使用 | いいえ |
claude_argsパラメータは、任意のClaude Code CLIの引数を受け入れます:claude_args:"--max-turns 5 --model claude-sonnet-4-5-20250929 --mcp-config /path/to/config.json"--max-turns: 最大会話ターン数(デフォルト:10)--model: 使用するモデル(例:claude-sonnet-4-5-20250929)--mcp-config: MCPの設定へのパス--allowed-tools: 許可されたツールのカンマ区切りリスト--debug: デバッグ出力を有効化/install-github-appコマンドが推奨されるアプローチですが、以下も可能です:CLAUDE.mdファイルを作成して、コーディング標準、レビュー基準、およびプロジェクト固有のルールを定義します。Claudeは、PRを作成してリクエストに応答する際に、これらのガイドラインに従います。詳細については、メモリドキュメントを確認してください。promptパラメータを使用して、ワークフロー固有の指示を提供します。これにより、異なるワークフローまたはタスク用にClaudeの動作をカスタマイズできます。このページは役に立ちましたか?