You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,7 +69,9 @@ on:
69
69
types: [created]
70
70
71
71
permissions:
72
-
contents: read
72
+
# write lets the action commit analysis.json to the PR branch so the comment can
73
+
# link to the webview diff. Drop to `read` to keep the comment without that link.
74
+
contents: write
73
75
pull-requests: write
74
76
issues: write
75
77
@@ -156,6 +158,7 @@ The command needs the `issue_comment` trigger and runs from your default branch
156
158
| `llm_api_key` | required | Your LLM provider API key (see `llm_provider`). |
157
159
| `llm_provider` | `openrouter` | Provider for the key, mapped to `<NAME>_API_KEY` (e.g. `anthropic`, `openai`, `google`). |
158
160
| `github_token` | `${{ github.token }}` | Token used to post or update the PR comment. |
161
+
| `push_token` | `${{ github.token }}` | Token used to push the generated `analysis.json` to the PR branch (for the webview link). The workflow token can push when the workflow grants `permissions: contents: write`. Separate from `github_token` so commenting can use a GitHub App token while the push uses the workflow token. |
Copy file name to clipboardExpand all lines: action.yml
+12-3Lines changed: 12 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,10 @@ inputs:
18
18
description: 'GITHUB_TOKEN used to post the PR comment. Defaults to the workflow token.'
19
19
required: false
20
20
default: ${{ github.token }}
21
+
push_token:
22
+
description: 'Token used to push the generated .codeboarding/analysis.json to the PR branch (for the webview link). Defaults to the workflow github.token, which can push when the calling workflow grants "permissions: contents: write". Kept separate from github_token so commenting can use a GitHub App token while the push uses the workflow token (whose write access the consumer controls).'
23
+
required: false
24
+
default: ${{ github.token }}
21
25
engine_ref:
22
26
description: 'Git ref (tag/branch/SHA) of CodeBoarding/CodeBoarding used as the analysis engine. Pinned to a release for reproducibility; override to track a newer ref.'
23
27
required: false
@@ -605,7 +609,10 @@ runs:
605
609
shell: bash
606
610
working-directory: target-repo
607
611
env:
608
-
GH_TOKEN: ${{ inputs.github_token }}
612
+
# Push with push_token (defaults to the workflow github.token, gated by the
613
+
# consumer's `permissions: contents: write`) — NOT github_token, which may be
614
+
# a GitHub App token used only for commenting and need not have write access.
615
+
GH_TOKEN: ${{ inputs.push_token }}
609
616
HEAD_DIR: ${{ steps.base.outputs.head_dir }}
610
617
HEAD_REF: ${{ steps.guard.outputs.head_ref }}
611
618
HEAD_SHA: ${{ steps.guard.outputs.head_sha }}
@@ -636,14 +643,16 @@ runs:
636
643
637
644
# Push to the PR head branch. The checkout used persist-credentials:false, so
638
645
# authenticate the push explicitly with the workflow token (same-repo only).
646
+
# Requires `contents: write` on the job's token — a read-only token (the
647
+
# default) is rejected here; the push error below names the cause.
if git push "$AUTH_URL" "HEAD:refs/heads/${HEAD_REF}" 2>/dev/null; then
649
+
if git push "$AUTH_URL" "HEAD:refs/heads/${HEAD_REF}"; then
641
650
NEW_SHA="$(git rev-parse HEAD)"
642
651
echo "webview_sha=$NEW_SHA" >> "$GITHUB_OUTPUT"
643
652
echo "ready=true" >> "$GITHUB_OUTPUT"
644
653
echo "Committed head analysis to ${HEAD_REF} as ${NEW_SHA}."
645
654
else
646
-
echo "::warning::Could not push head analysis to ${HEAD_REF}; the webview link will be omitted."
655
+
echo "::warning::Could not push head analysis to ${HEAD_REF}; the webview link will be omitted. Most likely the job's token lacks 'contents: write' (add 'permissions: contents: write' to the calling workflow), or the branch is protected against this pusher."
0 commit comments