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?

claude-code-actionがPrivateレポジトリ上でPRからPRを作成することが出来ない問題を解決する

0
Last updated at Posted at 2025-07-02

概要

claude-code-actionのレポジトリ上issueやFAQで語られていることではあるが
不明瞭なので備忘録として作成しておく

まず前提として
claude-code-actionでは以下の制約が与えられている
FAQより

なぜクロードは私のbashコマンドを実行しないのですか?
Bash ツールは、セキュリティ上の理由からデフォルトで無効になっています。

そのためなんらかの破壊的変更を伴う行動は実行できない
例えばフォルダ作成や自律的なPR作成など…以下のエラーが発生する
"Claude requested permissions to use Bash, but you haven't granted it yet."
またBash権限を指定しても動作しないこともある#74

また、MCPサーバもファイル処理とgit操作用のものが組込済みだがデフォルトでは許可されていない。
参照:https://github.com/anthropics/claude-code-action/issues/204

そのためここでは問題の解決の為bash許可及びclaude-code-actionsの許可を設定する。

対処法

要するにactionsで使用するymlファイルに以下の設定をする。

claude.yml
  claude:
    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 == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
      (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: read
      issues: read
      id-token: write
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 1

      - name: Run Claude Code
        id: claude
        uses: anthropics/claude-code-action@beta
        with:
          anthropic_api_key: ${{ secrets.claude_github }}
          allowed_tools: Bash,Bash(*),mcp__github__*
  • Bash,Bash(*)は諸説あるが#74での報告があったため両方入れておいた。
    片方だけでも動作する可能性は高いと思われる。
    • なお安全上の観点からbash(npm:*)など特定のコマンドに絞る事を推奨する。
    • その他denyの指定で禁止コマンドを設定できる。
  • mcp__github__*を追加することで明示的に組込済みMCPサーバの許可を付与することが可能

結論

claude-code-actionは非常に便利だがまだあまり情報が出揃っていない印象
活用したい人の役に立てば幸いである。
アップデートも頻繁に行われている為、変更等による問題があればコメントで教えてほしい

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?