みなさんは Claude Code Actions で複数のリポジトリを扱いたいと思ったことがありますか?
AIの発展とともに活用法が広がる中、そういうことができればなあと思ったことがある方もまあまあ多いと思います。
それってどうやって実現しましょう?
GitHub MCPを利用してマルチエージェント化?
Claude Code Actions のマルチリポジトリ対応を待つ??(2025/07/14時点で対応されていません)
今回は、いえいえ、そんなことは必要ありません。というお話をします。
この記事を読む際には、以下の前提を置きます。
- Claude Code Actions の環境構築を完了している
- Github Actions の知識が少しある
結論から言うと、actions/checkout をうまいこと使うことで
GitHub Actions のコンテナ上で、複数のリポジトリにチェックアウトすることが可能です。
example
プライベートリポジトリ、repo-a
と repo-b
があるとします。repo-a
に Actions の設定があり、repo-b
のソースコードを合わせて Claude Code Actions に読み込ませたい場合を想定してください。
下記に設定例を示します。
一番重要なことですが、プライベートリポジトリへの checkout は、GitHub Personal Access Token が必要ですが、GitHub App にリポジトリの読み取り権限があれば、GitHub App では、こうしたトークンを checkout 用にも流用可能です。
name: Claude Assistant
permissions:
contents: write
pull-requests: write
issues: write
id-token: write
on:
workflow_dispatch:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
jobs:
claude-assistant:
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: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@v2
with:
app-id: ***
private-key: ***
owner: ${{ github.repository_owner }}
repositories: |
repo-a
repo-b
- name: Checkout repository repo-a
uses: actions/checkout@v4
- name: Checkout repository repo-b
uses: actions/checkout@v4
with:
path: repo-b
repository: group/repo-b.git
token: ***
ref: master
- uses: google-github-actions/auth@v2
with:
project_id: ***
workload_identity_provider: ***
service_account: ***
- uses: anthropics/claude-code-action@beta
with:
trigger_phrase: "@claude"
timeout_minutes: "60"
github_token: ${{ steps.app-token.outputs.token }}
use_vertex: "true"
model: "***"
env:
ANTHROPIC_VERTEX_PROJECT_ID: ***
CLOUD_ML_REGION: ***
これはテクニックですが、この方法利用する際には、CLAUDE.md を利用して、どのリポジトリを参照して情報を得たかをパスベースで明示させた方がいいです。
最後に、GitHub Actionsではさまざまなツールが提供されていますが、そういったツールをうまく組み合わせることでAI開発もスケールさせることができそうですね。みなさんの参考になれば幸いです。
Views: 0