|
| 1 | +name: PR Pipeline |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, synchronize, reopened] |
| 6 | + issue_comment: |
| 7 | + types: [created] |
| 8 | + pull_request_review_comment: |
| 9 | + types: [created] |
| 10 | + |
| 11 | +jobs: |
| 12 | + shellcheck: |
| 13 | + name: ShellCheck |
| 14 | + # Only run for the repo owner — block random fork PRs from consuming CI |
| 15 | + if: github.event_name == 'pull_request' && github.actor == 'injectedfusion' |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + |
| 22 | + - name: Get changed shell scripts |
| 23 | + id: changed |
| 24 | + env: |
| 25 | + BASE_REF: ${{ github.base_ref }} |
| 26 | + run: | |
| 27 | + files=$(git diff --name-only --diff-filter=ACMR "origin/$BASE_REF"...HEAD -- '*.sh' | tr '\n' ' ') |
| 28 | + echo "files=$files" >> "$GITHUB_OUTPUT" |
| 29 | + if [ -n "$files" ]; then |
| 30 | + echo "has_files=true" >> "$GITHUB_OUTPUT" |
| 31 | + fi |
| 32 | +
|
| 33 | + - name: Install shellcheck |
| 34 | + if: steps.changed.outputs.has_files == 'true' |
| 35 | + run: sudo apt-get install -y shellcheck |
| 36 | + |
| 37 | + - name: Run shellcheck on changed scripts |
| 38 | + if: steps.changed.outputs.has_files == 'true' |
| 39 | + env: |
| 40 | + CHANGED_FILES: ${{ steps.changed.outputs.files }} |
| 41 | + run: | |
| 42 | + exit_code=0 |
| 43 | + for f in $CHANGED_FILES; do |
| 44 | + [ -f "$f" ] || continue |
| 45 | + echo "::group::Checking $f" |
| 46 | + shellcheck -S warning "$f" 2>&1 |
| 47 | + result=$? |
| 48 | + echo "::endgroup::" |
| 49 | + if [ $result -ne 0 ]; then |
| 50 | + echo "::error file=$f::shellcheck found issues" |
| 51 | + exit_code=1 |
| 52 | + fi |
| 53 | + done |
| 54 | + exit $exit_code |
| 55 | +
|
| 56 | + # --- Claude Review (waits for CI on PRs, runs directly on @claude mentions) --- |
| 57 | + |
| 58 | + review: |
| 59 | + needs: [shellcheck] |
| 60 | + # Only the repo owner can trigger reviews — prevents billing abuse on public repo |
| 61 | + if: | |
| 62 | + always() && github.actor == 'injectedfusion' && |
| 63 | + ( |
| 64 | + (github.event_name == 'pull_request' && |
| 65 | + needs.shellcheck.result != 'failure') || |
| 66 | + (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || |
| 67 | + (github.event_name == 'pull_request_review_comment') |
| 68 | + ) |
| 69 | + runs-on: ubuntu-latest |
| 70 | + permissions: |
| 71 | + actions: read |
| 72 | + contents: write |
| 73 | + pull-requests: write |
| 74 | + id-token: write |
| 75 | + steps: |
| 76 | + - uses: actions/checkout@v4 |
| 77 | + with: |
| 78 | + fetch-depth: 1 |
| 79 | + |
| 80 | + - uses: anthropics/claude-code-action@v1 |
| 81 | + env: |
| 82 | + PR_NUMBER: ${{ github.event.pull_request.number }} |
| 83 | + REPO: ${{ github.repository }} |
| 84 | + with: |
| 85 | + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} |
| 86 | + track_progress: true |
| 87 | + prompt: | |
| 88 | + REPO: ${{ env.REPO }} |
| 89 | + PR NUMBER: ${{ env.PR_NUMBER }} |
| 90 | +
|
| 91 | + You are the sole code reviewer for this repository. Your review decision |
| 92 | + determines whether this PR merges to the main branch. |
| 93 | +
|
| 94 | + This repo contains reusable pre-commit hooks (bash scripts + .pre-commit-hooks.yaml). |
| 95 | + Review this PR focusing on: |
| 96 | + - Shell script correctness and safety (quoting, error handling, set -euo pipefail) |
| 97 | + - Security (no credential leaks, no unsafe eval/exec patterns) |
| 98 | + - Hook configuration validity (.pre-commit-hooks.yaml fields) |
| 99 | + - Documentation accuracy (comments match actual behavior) |
| 100 | +
|
| 101 | + After your review: |
| 102 | + - Use inline comments for specific code issues. |
| 103 | + - Post a single PR comment with your overall summary. |
| 104 | + - If the PR is acceptable: approve it with `gh pr review --approve` and |
| 105 | + then merge it with `gh pr merge --squash --auto`. |
| 106 | + - If the PR has issues that must be fixed: request changes with |
| 107 | + `gh pr review --request-changes` and do NOT merge. |
| 108 | +
|
| 109 | + claude_args: | |
| 110 | + --model claude-haiku-4-5-20251001 --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr review:*),Bash(gh pr merge:*)" |
0 commit comments