Skip to content

ci: add automated PR review bot workflow - #1505

Open
hs-agent wants to merge 3 commits into
mainfrom
add-review-bot-workflow
Open

ci: add automated PR review bot workflow#1505
hs-agent wants to merge 3 commits into
mainfrom
add-review-bot-workflow

Conversation

@hs-agent

Copy link
Copy Markdown

Type of Change

  • CI/CD

Description

Adds a GitHub Actions workflow that wires this repo up to the shared OpenCode review bot infrastructure.

When someone comments `@hyperswitch-web-review-bot` on a PR, a self-hosted runner:

  1. Pulls the latest `hyperswitch-web-reviewer` skill from `juspay/hyperswitch-specs` (source of truth for the team's review rules and checklist).
  2. Runs an OpenCode agent that classifies the comment intent (`review` / `feedback` / `answer` / `update`) and dispatches to the matching handler.
  3. Posts inline review findings, thread replies, or opens a PR against the spec repo when someone requests a rule update.

The workflow is parameterized via a top-level `env:` block (team name, skill name, repo, runner-local paths), so reusing it for another team only requires changing those values. Same template is already live on `juspay/hyperswitch-control-center` (#4708).

How did you test it?

  • Verified the end-to-end flow on `juspay/hyperswitch-control-center` PR #4631 — review, feedback thread reply, and `/update` → spec-repo PR → merge → rule re-sync all work.
  • Smoke-tested the sync step locally on the runner (`git pull` + `cp -r`) against the existing `hyperswitch-web-reviewer` skill in the spec repo.

Checklist

  • I ran `npm run re:build`
  • I reviewed submitted code
  • I added unit tests for my changes where possible

Adds parameterized workflow for @hyperswitch-web-review-bot

- Syncs skill from juspay/hyperswitch-specs

- Supports review, feedback, answer, and update intents
@hs-agent
hs-agent requested a review from seekshiva as a code owner April 15, 2026 08:13
@semanticdiff-com

semanticdiff-com Bot commented Apr 15, 2026

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  .github/workflows/review-bot.yml  0% smaller

Restrict the review-bot workflow to comments from OWNER/MEMBER/COLLABORATOR
so external users can't drive-by trigger a self-hosted runner by commenting
the bot mention on a fork PR. Closes the public drive-by attack path until
we migrate the bot to a webhook-based service.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Brings this workflow to parity with the hardening already being landed
on juspay/hyperswitch-control-center#4741 and present in
juspay/hyperswitch-prism#1145.

- concurrency group keyed on PR number (cancel-in-progress: false) —
  two mentions on the same PR no longer race on the shared
  $SOURCE_REPO_LOCAL checkout.
- job + step-level timeout-minutes: 30 — kills runaway opencode
  sessions instead of pinning the self-hosted runner indefinitely.
- defaults.run.shell: bash — explicit shell instead of the default.
- set -euo pipefail on every script step — propagates failures
  instead of masking them.
- skill source directory existence check before cp — fails loud if
  hyperswitch-specs is missing the skill rather than producing an
  empty install.
- empty-branch guard around `git checkout` — avoids `git checkout ""`
  when `gh pr view` returns nothing.
- unique session title `review-$TEAM-$PR-$GITHUB_RUN_ID` + stale
  session retry — the prior `head -1` on session list could return
  the wrong session if titles collided across runs; each run now
  creates a uniquely titled session and falls back to a fresh one
  if resume fails.
- new Acknowledge trigger with eye reaction step — posts an 👀
  reaction on the triggering comment as soon as the job starts
  executing, giving the user who mentioned @hyperswitch-web-review-bot
  immediate feedback that the bot received the trigger rather than
  waiting 1-3 minutes for the review itself. Non-fatal on failure.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kanikabansal08 kanikabansal08 linked an issue Apr 20, 2026 that may be closed by this pull request
exit 1
fi
git checkout "$BRANCH"
git pull origin "$BRANCH"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How will this work for PRs using fork?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The workflow yaml always runs from juspay/hyperswitch's main and never from the fork.

Comment on lines +14 to +16
concurrency:
group: hyperswitch-web-review-${{ github.event.issue.number || github.event.pull_request.number }}
cancel-in-progress: false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

how does this handle two different PR review at the same time?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

it keeps the other in queue. runner picks one job at a time.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

concurrency group is scoped per PR number, so different PRs can still run simultaneously, right?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No, because we currently have only one self-hosted runner, so effectively workflows across PRs also end up running one at a time.

Right now the concurrency config only serializes runs within the same PR.

Comment on lines +131 to +158
SKILL_NAME : $SKILL_NAME
SOURCE_REPO : $SOURCE_REPO
SOURCE_REPO_LOCAL : $SOURCE_REPO_LOCAL

TRIGGER CONTEXT:
Event : $EVENT_NAME
PR : #$PR_NUMBER
Comment : $COMMENT_BODY
In reply to : $IN_REPLY_TO"

if [ -f "$SESSION_FILE" ]; then
SAVED_ID=$(cat "$SESSION_FILE")
echo "Resuming session $SAVED_ID for review #$PR_NUMBER"
if opencode run \
--session "$SAVED_ID" \
--dir "$SOURCE_REPO_LOCAL" \
"$PROMPT"; then
echo "Resumed session $SAVED_ID successfully"
exit 0
else
echo "Session $SAVED_ID failed, creating new session"
rm -f "$SESSION_FILE"
fi
fi

UNIQUE_TITLE="review-$TEAM_NAME-$PR_NUMBER-$GITHUB_RUN_ID"
echo "Creating new session for review #$PR_NUMBER"
opencode run \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need to expose file paths, agent commands, and prompts directly in the workflow? Instead, why not encapsulate the business logic in a .sh script on the host machine and use GitHub Actions only to trigger that script? This would keep the workflow cleaner, reduce exposure of internal implementation details, and make the logic easier to maintain.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The workflow is doing exactly one thing, in a fixed way, and putting it all in one file makes that thing legible.
These agent commands are deterministic code. Nothing in the current design is exploitable because paths and prompts are public.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: add automated PR review bot workflow

4 participants