Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/dispatch-code-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Dispatch Code Review

# Lightweight relay — on PR ready (not every push), dispatches the centralized
# ocr/Gemini review in AltimateAI/altimate-qa (code-review.yml).
#
# Gated loop: review fires only when a PR is opened non-draft or marked Ready for
# review. `synchronize` is intentionally omitted so pushes don't re-trigger.
# altimate-qa flips the PR back to draft on CRITICAL findings, so re-review happens
# on the next ready_for_review after the author addresses them.
#
# Token: reuses the org-level AUTOPILOT_DISPATCH_TOKEN (same one dbt-integration /
# vscode-dbt-power-user use to dispatch to altimate-qa). If that org secret is not
# visible to this repo, the step skips cleanly — ask an admin to extend its repo
# visibility (no new token needs to be created).

on:
pull_request:
types: [opened, ready_for_review]
branches: [main]

concurrency:
group: dispatch-code-review-${{ github.event.pull_request.number }}
cancel-in-progress: true

permissions:
contents: read

jobs:
dispatch:
name: Notify altimate-qa
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
timeout-minutes: 2
steps:
- name: Dispatch to centralized code review
env:
GH_TOKEN: ${{ secrets.AUTOPILOT_DISPATCH_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
if [ -z "$GH_TOKEN" ]; then
echo "AUTOPILOT_DISPATCH_TOKEN not available to altimate-code — skipping centralized dispatch."
echo "Ask an org admin to extend that org secret's visibility to AltimateAI/altimate-code."
exit 0
fi
gh api repos/AltimateAI/altimate-qa/dispatches \
--method POST \
-f event_type=code-review \
-f "client_payload[repo]=AltimateAI/altimate-code" \
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot Jun 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use dynamic repository reference instead of hardcoded value.

The repository name is hardcoded as AltimateAI/altimate-code. If this workflow is copied to another repository or the repository is renamed, it will send incorrect metadata to the centralized review service.

♻️ Proposed fix

Use the GitHub context variable instead:

-            -f "client_payload[repo]=AltimateAI/altimate-code" \
+            -f "client_payload[repo]=${{ github.repository }}" \

Note: This fix is included in the JSON-based approach suggested for the shell injection fix above.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
-f "client_payload[repo]=AltimateAI/altimate-code" \
-f "client_payload[repo]=${{ github.repository }}" \
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/dispatch-code-review.yml at line 52, The workflow
currently hardcodes the repository value in the curl payload
(client_payload[repo]=AltimateAI/altimate-code); update the dispatch payload to
use the GitHub Actions repository context instead (e.g., use the
GITHUB_REPOSITORY/GITHUB_REPOSITORY env or the github.repository context) so
client_payload[repo] is set dynamically; locate the line that sets
client_payload[repo] and replace the literal string with the appropriate
variable reference (using the same shell/templating style used elsewhere in the
workflow) to ensure the correct repository is sent.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair, minor. The literal AltimateAI/altimate-code is correct because this workflow only ever runs in this repo, but ${{ github.repository }} (or $GITHUB_REPOSITORY) is cleaner and copy-paste-safe. If this PR lands, we'll switch the payload to the GitHub-provided repo context (alongside a jq-built JSON body).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dev-punia-altimate, that sounds like a solid plan — using $GITHUB_REPOSITORY together with a jq-built JSON body addresses both this concern and the shell-injection risk in one pass. Would you like me to open a follow-up issue to track the $GITHUB_REPOSITORY + jq payload refactor so it doesn't get lost?

-f "client_payload[pr_number]=$PR_NUMBER" \
-f "client_payload[head_ref]=$PR_HEAD_REF" \
-f "client_payload[head_sha]=$PR_HEAD_SHA" \
-f "client_payload[author]=$PR_AUTHOR" \
-f "client_payload[title]=$PR_TITLE"
echo "Dispatched code review for PR #$PR_NUMBER"
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Loading