Skip to content

Commit 7c67083

Browse files
committed
fix(action): 事前権限チェックを廃止し失敗時の警告スキップに変更
Claude GitHub Appのトークンは事前に検証できないため、 事前のpending reviewによる権限チェックを削除しました。 代わりにclaude-code-actionにcontinue-on-errorを付けて、 失敗時は警告を出してワークフローを止めないようにしています。
1 parent fa1d262 commit 7c67083

1 file changed

Lines changed: 10 additions & 43 deletions

File tree

action.yml

Lines changed: 10 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -159,49 +159,7 @@ runs:
159159
exit 1
160160
fi
161161
162-
# Check pull-requests:write permission on the explicitly provided github_token.
163-
# GitHub often restricts token permissions for security reasons,
164-
# e.g. when workflow files are modified in a PR. Detect this early.
165-
#
166-
# When github_token is omitted, claude-code-action uses Claude GitHub App
167-
# which manages its own token, so we skip this check entirely.
168-
#
169-
# There is no API endpoint to query individual GITHUB_TOKEN permissions,
170-
# so we create a pending review and immediately delete it.
171-
# Pending reviews are invisible to other users until submitted.
172-
# This requires pull-requests:write, which is exactly what we need to verify.
173-
- name: Check GitHub token permissions
174-
if: inputs.github_token != ''
175-
id: check-token
176-
shell: bash
177-
env:
178-
GH_TOKEN: ${{ inputs.github_token }}
179-
REPO: ${{ github.repository }}
180-
PR_NUMBER: ${{ github.event.pull_request.number }}
181-
run: |
182-
if [[ -z "$PR_NUMBER" ]]; then
183-
echo "skip=true" >> "$GITHUB_OUTPUT"
184-
exit 0
185-
fi
186-
187-
endpoint="repos/$REPO/pulls/$PR_NUMBER/reviews"
188-
189-
if review_id=$(gh api "$endpoint" \
190-
-X POST --jq '.id' 2>/dev/null)
191-
then
192-
gh api "$endpoint/$review_id" \
193-
-X DELETE 2>/dev/null || true
194-
else
195-
msg="GITHUB_TOKEN lacks pull-requests:write."
196-
msg+=" Review comments will not be posted."
197-
msg+=" Common causes: workflow file changes"
198-
msg+=" in this PR, or fork PRs."
199-
echo "::warning::$msg"
200-
echo "skip=true" >> "$GITHUB_OUTPUT"
201-
fi
202-
203162
- name: Build allowed tools list
204-
if: steps.check-token.outputs.skip != 'true'
205163
id: build-allowed-tools
206164
shell: bash
207165
env:
@@ -215,8 +173,8 @@ runs:
215173
echo "joined=$joined" >> "$GITHUB_OUTPUT"
216174
217175
- name: Run Kyosei
218-
if: steps.check-token.outputs.skip != 'true'
219176
id: claude-review
177+
continue-on-error: true
220178
uses: anthropics/claude-code-action@88c168b39e7e64da0286d812b6e9fbebb6708185 # v1.0.82
221179
with:
222180
claude_code_oauth_token: ${{ inputs.claude_code_oauth_token }}
@@ -233,3 +191,12 @@ runs:
233191
--model "${{ inputs.model }}"
234192
--allowed-tools "${{ steps.build-allowed-tools.outputs.joined }}"
235193
${{ inputs.claude_args }}
194+
195+
# If claude-code-action fails, emit a warning instead of failing the workflow.
196+
# Common causes: insufficient token permissions (e.g. workflow file changes
197+
# in the PR, fork PRs) or transient API errors.
198+
- name: Handle failure
199+
if: steps.claude-review.outcome == 'failure'
200+
shell: bash
201+
run: |
202+
echo "::warning::Kyosei failed. This may be due to insufficient token permissions (e.g. workflow file changes in this PR, or fork PRs) or a transient error. Skipping."

0 commit comments

Comments
 (0)