|
| 1 | +# Template: copy this file into a target repo at .github/workflows/coderabbit-autofix.yml |
| 2 | +# |
| 3 | +# Seeded by .github/workflows/enforce-repo-settings.yml fleet-wide. |
| 4 | +# |
| 5 | +# Auto-comments `@coderabbitai autofix` on every PR open/sync from a |
| 6 | +# non-bot author. CodeRabbit's Autofix (Beta, Pro plan, GitHub only) then |
| 7 | +# pushes a commit to the PR branch with fixes for every unresolved CR |
| 8 | +# review thread that carries a structured `Prompt for AI Agents` block. |
| 9 | +# See https://docs.coderabbit.ai/finishing-touches/autofix. |
| 10 | +# |
| 11 | +# This template specifically requests the "Push a commit to this branch" |
| 12 | +# path (default `@coderabbitai autofix` semantics — not `autofix stacked |
| 13 | +# pr`) so the fix lands on the same branch and native auto-merge can |
| 14 | +# carry the PR forward without human intervention. |
| 15 | +# |
| 16 | +# Skip conditions: |
| 17 | +# - PRs opened by CodeRabbit itself (its own follow-up PRs). |
| 18 | +# - PRs from Dependabot / Renovate / Copilot agent (already AI-shaped; |
| 19 | +# no human review block to autofix). |
| 20 | +# - PRs carrying the `skip-autofix` label (explicit opt-out). |
| 21 | + |
| 22 | +name: CodeRabbit Autofix Trigger |
| 23 | + |
| 24 | +on: |
| 25 | + pull_request: |
| 26 | + types: [opened, synchronize] |
| 27 | + |
| 28 | +permissions: |
| 29 | + contents: read |
| 30 | + pull-requests: write |
| 31 | + |
| 32 | +jobs: |
| 33 | + trigger: |
| 34 | + if: | |
| 35 | + github.actor != 'coderabbitai[bot]' && |
| 36 | + github.actor != 'dependabot[bot]' && |
| 37 | + github.actor != 'renovate[bot]' && |
| 38 | + github.actor != 'copilot[bot]' && |
| 39 | + !contains(github.event.pull_request.labels.*.name, 'skip-autofix') |
| 40 | + concurrency: |
| 41 | + group: coderabbit-autofix-${{ github.event.pull_request.number }} |
| 42 | + cancel-in-progress: true |
| 43 | + runs-on: ubuntu-latest |
| 44 | + steps: |
| 45 | + - name: Comment "@coderabbitai autofix" |
| 46 | + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9 |
| 47 | + with: |
| 48 | + script: | |
| 49 | + await github.rest.issues.createComment({ |
| 50 | + owner: context.repo.owner, |
| 51 | + repo: context.repo.repo, |
| 52 | + issue_number: context.issue.number, |
| 53 | + body: '@coderabbitai autofix' |
| 54 | + }); |
0 commit comments