Skip to content

Commit 27afda0

Browse files
committed
docs: document CI re-triggering limitation and fork PR incompatibility
- docs/permissions.md: Add warning about GITHUB_TOKEN not triggering CI on auto-fix commits, with PAT workaround. Add warning about third-party fork PRs where auto-fix cannot work. - action.yml: Add intelligent fork-detection in push failure warning (checks for 403/refused/permission errors and shows context-aware message referencing docs). - .github/workflows/examples/auto-fix.yml: Add comment about PAT option for CI re-triggering.
1 parent e751598 commit 27afda0

3 files changed

Lines changed: 35 additions & 2 deletions

File tree

.github/workflows/examples/auto-fix.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ jobs:
1212
pull-requests: write
1313
steps:
1414
- uses: actions/checkout@v5
15+
# For auto-fix commits to trigger new CI runs, use a PAT instead:
16+
# with:
17+
# token: ${{ secrets.MY_PAT }}
1518

1619
- uses: cpp-linter/cpp-linter-action@v2
1720
id: linter

action.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,12 @@ runs:
538538
let branch = $env.GITHUB_HEAD_REF | default $env.GITHUB_REF_NAME
539539
let push_result = (^git push origin $"HEAD:refs/heads/($branch)") | complete
540540
if $push_result.exit_code != 0 {
541-
print $"::warning title=Auto-fix push failed::(ansi yellow)($push_result.stderr)(ansi reset)"
541+
let stderr_lower = ($push_result.stderr | str downcase)
542+
if ($stderr_lower | str contains "403") or ($stderr_lower | str contains "refused") or ($stderr_lower | str contains "not have permission") {
543+
print $"::warning title=Auto-fix push failed::This action does not have permission to push to this branch. When using auto-fix on pull_request events from a third-party fork, the GITHUB_TOKEN cannot write to the fork repository. See docs/permissions.md for details.(ansi reset)"
544+
} else {
545+
print $"::warning title=Auto-fix push failed::(ansi yellow)($push_result.stderr)(ansi reset)"
546+
}
542547
} else {
543548
print $"(ansi green)Auto-fix commit pushed successfully(ansi reset)"
544549
}

docs/permissions.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ The [`tidy-review`](inputs-outputs.md#tidy-review), [`format-review`](inputs-out
8181
8282
## Auto-fix
8383
84-
The [`auto-fix`](inputs-outputs.md#auto-fix) feature requires the following permission
84+
The [`auto-fix`](inputs-outputs.md#auto-fix) feature requires `contents: write` permission
8585
in addition to any other permissions needed for other features:
8686

8787
```yaml
@@ -90,3 +90,28 @@ in addition to any other permissions needed for other features:
9090
```
9191

9292
1. Needed to commit and push the formatted changes back to the PR branch.
93+
94+
!!! warning "CI re-triggering with auto-fix"
95+
96+
The default `GITHUB_TOKEN` **cannot** trigger new CI runs when pushing
97+
a commit. If you need the auto-fix commit to trigger CI checks
98+
(e.g. to verify the fix builds clean), use a personal access token
99+
(PAT) with `contents: write` scope:
100+
101+
```yaml
102+
- uses: actions/checkout@v5
103+
with:
104+
token: ${{ secrets.MY_PAT }}
105+
```
106+
107+
When using the default `GITHUB_TOKEN`, you can include `[skip ci]` in
108+
the auto-fix commit message to avoid unnecessary CI runs on the
109+
fix commit itself. See the [`auto-fix-commit-msg`](./inputs-outputs.md#auto-fix-commit-msg) input.
110+
111+
!!! warning "Pull requests from third-party forks"
112+
113+
Auto-fix does not work on pull requests from third-party forks. The
114+
`GITHUB_TOKEN` lacks write permission to the fork repository, and
115+
`git push` to the fork's branch is not possible. Consider
116+
restricting `auto-fix` to `push` events or pull requests from the
117+
same repository.

0 commit comments

Comments
 (0)