|
| 1 | +name: Dispatch Code Review |
| 2 | + |
| 3 | +# Lightweight relay — on PR ready (not every push), dispatches the centralized |
| 4 | +# ocr/Gemini review in AltimateAI/altimate-qa (code-review.yml). |
| 5 | +# |
| 6 | +# Gated loop: review fires only when a PR is opened non-draft or marked Ready for |
| 7 | +# review. `synchronize` is intentionally omitted so pushes don't re-trigger. |
| 8 | +# altimate-qa flips the PR back to draft on CRITICAL findings, so re-review happens |
| 9 | +# on the next ready_for_review after the author addresses them. |
| 10 | +# |
| 11 | +# Token: reuses the org-level AUTOPILOT_DISPATCH_TOKEN (same one dbt-integration / |
| 12 | +# vscode-dbt-power-user use to dispatch to altimate-qa). If that org secret is not |
| 13 | +# visible to this repo, the step skips cleanly — ask an admin to extend its repo |
| 14 | +# visibility (no new token needs to be created). |
| 15 | + |
| 16 | +on: |
| 17 | + pull_request: |
| 18 | + types: [opened, ready_for_review] |
| 19 | + branches: [main] |
| 20 | + |
| 21 | +concurrency: |
| 22 | + group: dispatch-code-review-${{ github.event.pull_request.number }} |
| 23 | + cancel-in-progress: true |
| 24 | + |
| 25 | +permissions: |
| 26 | + contents: read |
| 27 | + |
| 28 | +jobs: |
| 29 | + dispatch: |
| 30 | + name: Notify altimate-qa |
| 31 | + runs-on: ubuntu-latest |
| 32 | + if: github.event.pull_request.draft == false |
| 33 | + timeout-minutes: 2 |
| 34 | + steps: |
| 35 | + - name: Dispatch to centralized code review |
| 36 | + env: |
| 37 | + GH_TOKEN: ${{ secrets.AUTOPILOT_DISPATCH_TOKEN }} |
| 38 | + PR_NUMBER: ${{ github.event.pull_request.number }} |
| 39 | + PR_HEAD_REF: ${{ github.event.pull_request.head.ref }} |
| 40 | + PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} |
| 41 | + PR_AUTHOR: ${{ github.event.pull_request.user.login }} |
| 42 | + PR_TITLE: ${{ github.event.pull_request.title }} |
| 43 | + run: | |
| 44 | + if [ -z "$GH_TOKEN" ]; then |
| 45 | + echo "AUTOPILOT_DISPATCH_TOKEN not available to altimate-code — skipping centralized dispatch." |
| 46 | + echo "Ask an org admin to extend that org secret's visibility to AltimateAI/altimate-code." |
| 47 | + exit 0 |
| 48 | + fi |
| 49 | + gh api repos/AltimateAI/altimate-qa/dispatches \ |
| 50 | + --method POST \ |
| 51 | + -f event_type=code-review \ |
| 52 | + -f "client_payload[repo]=AltimateAI/altimate-code" \ |
| 53 | + -f "client_payload[pr_number]=$PR_NUMBER" \ |
| 54 | + -f "client_payload[head_ref]=$PR_HEAD_REF" \ |
| 55 | + -f "client_payload[head_sha]=$PR_HEAD_SHA" \ |
| 56 | + -f "client_payload[author]=$PR_AUTHOR" \ |
| 57 | + -f "client_payload[title]=$PR_TITLE" |
| 58 | + echo "Dispatched code review for PR #$PR_NUMBER" |
0 commit comments