|
13 | 13 | jobs: |
14 | 14 | claude-review: |
15 | 15 | # Skip PRs we shouldn't (or can't) review: |
16 | | - # - Dependabot / forks: no CLAUDE_CODE_OAUTH_TOKEN, so the action would fail. |
| 16 | + # - Dependabot / forks: no OIDC token to exchange, so the action would fail. |
17 | 17 | # - release-please release PRs: just version bumps + changelog — nothing to |
18 | 18 | # review, and it must never block a release. |
19 | 19 | # - Back-merge PRs (production -> dev, opened by release-please.yml): only |
|
44 | 44 | id: claude-review |
45 | 45 | uses: anthropics/claude-code-action@v1 |
46 | 46 | with: |
47 | | - claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} |
| 47 | + # Workload identity federation: the action swaps the job's GitHub OIDC |
| 48 | + # token (hence `id-token: write`) for a short-lived Anthropic token. |
| 49 | + # No stored secret. These IDs aren't secret either. |
| 50 | + anthropic_federation_rule_id: fdrl_01TQKFjxagS7QzsRp6royjYN |
| 51 | + anthropic_organization_id: 43f1fdcd-16a2-46c9-902d-f939b82bb4f4 |
| 52 | + anthropic_service_account_id: svac_01TcDsbHiTCxQ5m7aNHrBgLg |
| 53 | + anthropic_workspace_id: wrkspc_01SadkG1A6MDwLr3FVD1VmyN |
48 | 54 | plugin_marketplaces: 'https://github.com/anthropics/claude-code.git' |
49 | 55 | plugins: 'code-review@claude-code-plugins' |
50 | 56 | # --comment is required for the review to be posted to the PR: the |
@@ -76,12 +82,26 @@ jobs: |
76 | 82 | # The plugin also stops early on PRs it judges trivial. The prompt above |
77 | 83 | # tells Claude to post a one-line note in that case, so a deliberate skip |
78 | 84 | # leaves a comment and only a real failure trips this check. |
| 85 | + # |
| 86 | + # Nor is a PR that edits THIS file: the action refuses to run unless the |
| 87 | + # workflow is identical to the default branch's ("Workflow validation |
| 88 | + # failed"), a deliberate guard against a PR rewriting its own reviewer. It |
| 89 | + # exits green having posted nothing, so pass with a notice instead. |
79 | 90 | - name: Check a review comment was posted |
80 | 91 | env: |
81 | 92 | GH_TOKEN: ${{ github.token }} |
82 | 93 | REPO: ${{ github.repository }} |
83 | 94 | PR: ${{ github.event.pull_request.number }} |
| 95 | + SELF: ${{ github.workflow_ref }} |
84 | 96 | run: | |
| 97 | + # workflow_ref is "owner/repo/.github/workflows/<file>@<ref>". |
| 98 | + self_path="${SELF#"$REPO"/}" |
| 99 | + self_path="${self_path%@*}" |
| 100 | + if gh api "repos/$REPO/pulls/$PR/files" --paginate --jq '.[].filename' | grep -qxF "$self_path"; then |
| 101 | + echo "::notice::This PR edits $self_path, so the review action skipped it by design (it only runs the default branch's version of its own workflow). No review on this PR." |
| 102 | + exit 0 |
| 103 | + fi |
| 104 | +
|
85 | 105 | # Prints the time of every claude[bot] comment, inline comment and review. |
86 | 106 | claude_posts() { |
87 | 107 | gh api "repos/$REPO/issues/$PR/comments" --paginate \ |
|
0 commit comments