Files
ghbot/.github/workflows/review-reusable.yml
lezi-fun 9e47ab339e feat: sync ghbot-Nodeloc v1.2.0 capabilities into upstream
Merges all 33 commits from lza6/ghbot-Nodeloc (v1.0.0 through v1.2.0)
while keeping both sides' features in every conflicted file:

- EventRouter dispatch extracted from runReview.ts (7.1), with the
  runtime environment block preserved on the review-start comment
- Unified command ack messages (6.3) combined with the collapsed
  runtime environment block and bot signature on /recheck replies
- Status banner and collapsible unposted findings in review bodies (6.1)
- Centralized runtime directories behind GHBOT_RUNTIME_DIR (D-13);
  webhook knowledge cache now lives under tempRootDirectory()
- Production hardening for merge races, timeouts, webhook ops;
  atomic temp-file rename for R2 cache restores kept from upstream
- Webhook parity retained: triage events gated by WEBHOOK_TRIAGE_ENABLED,
  read-only command guidance, repository knowledge injection,
  runtime environment block on webhook chat replies
- Sanitization/secret redaction centralization, error-aware retry,
  duplicate merge prevention, in-process webhook retries, /metrics
- Infra: eslint/prettier gates with CI verify workflow, docs archives

typecheck, eslint, prettier format:check, and 164 tests all pass.
2026-08-24 11:47:28 +08:00

351 lines
12 KiB
YAML

name: Reusable PR Review Bot
on:
workflow_call:
inputs:
event_name:
required: true
type: string
event_action:
required: true
type: string
repository_owner:
required: true
type: string
repository_name:
required: true
type: string
repository_id:
required: false
type: string
default: ""
pull_number:
required: true
type: string
pull_head_repository:
required: false
type: string
default: ""
comment_id:
required: false
type: string
default: ""
commenter_login:
required: false
type: string
default: ""
comment_body:
required: false
type: string
default: ""
reviewer_login:
required: false
type: string
default: ""
review_state:
required: false
type: string
default: ""
review_commit_id:
required: false
type: string
default: ""
bot_name:
required: false
type: string
default: github-actions[bot]
goose_base_url:
required: false
type: string
default: ""
goose_model:
required: false
type: string
default: ""
goose_thinking_effort:
required: false
type: string
default: ""
opencode_base_url:
required: false
type: string
default: https://api.openai.com/v1
opencode_model:
required: false
type: string
default: gpt-5.4
opencode_reasoning_effort:
required: false
type: string
default: high
review_policy:
required: false
type: string
default: allow
review_strictness:
required: false
type: string
default: normal
review_instructions:
required: false
type: string
default: ""
review_branches:
required: false
type: string
default: ""
repository_knowledge_enabled:
required: false
type: string
default: "true"
repository_knowledge_write:
required: false
type: string
default: "false"
r2_endpoint:
required: false
type: string
default: ""
r2_bucket_name:
required: false
type: string
default: ""
r2_prefix:
required: false
type: string
default: ""
triage_enabled:
required: false
type: string
default: "true"
triage_labels:
required: false
type: string
default: bug,enhancement,documentation,question,maintenance
triage_duplicate_label:
required: false
type: string
default: duplicate
triage_candidate_limit:
required: false
type: string
default: "50"
triage_instructions:
required: false
type: string
default: ""
auto_merge:
required: false
type: string
default: "false"
auto_resolve_conflicts:
required: false
type: string
default: "false"
conflict_test_command:
required: false
type: string
default: ""
merge_method:
required: false
type: string
default: squash
require_checks:
required: false
type: string
default: "true"
max_patch_chars:
required: false
type: string
default: "120000"
runtime_directory:
required: false
type: string
default: ""
log_level:
required: false
type: string
default: info
run_schedule_recheck:
required: false
type: string
default: "false"
secrets:
GOOSE_API_KEY:
required: false
OPENCODE_API_KEY:
required: false
GH_APP_ID:
required: false
GH_APP_PRIVATE_KEY:
required: false
GH_APP_INSTALLATION_ID:
required: false
R2_ACCESS_KEY_ID:
required: false
R2_SECRET_ACCESS_KEY:
required: false
permissions:
contents: write
pull-requests: write
checks: write
statuses: read
issues: write
jobs:
review:
name: bot-review
if: ${{ inputs.run_schedule_recheck != 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: lezi-fun/ghbot
ref: main
path: ghbot-runtime
- name: Check out current PR source for agent tasks
if: ${{ inputs.event_name == 'issue_comment' || (inputs.event_name == 'pull_request_target' && inputs.event_action != 'closed' && inputs.auto_resolve_conflicts == 'true' && inputs.pull_head_repository == format('{0}/{1}', inputs.repository_owner, inputs.repository_name)) }}
uses: actions/checkout@v4
with:
repository: ${{ inputs.repository_owner }}/${{ inputs.repository_name }}
ref: refs/pull/${{ inputs.pull_number }}/head
path: pr-worktree
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: 24
- name: Install goose CLI
env:
GOOSE_VERSION: v1.46.0
GOOSE_BIN_DIR: ${{ runner.temp }}/goose/bin
CONFIGURE: "false"
run: |
curl -fsSL "https://github.com/aaif-goose/goose/releases/download/${GOOSE_VERSION}/download_cli.sh" | bash
echo "${GOOSE_BIN_DIR}" >> "${GITHUB_PATH}"
- run: npm ci
working-directory: ghbot-runtime
- run: npm run build
working-directory: ghbot-runtime
- run: node dist/src/actions/runReview.js
working-directory: ghbot-runtime
env:
GITHUB_TOKEN: ${{ github.token }}
GOOSE_API_KEY: ${{ secrets.GOOSE_API_KEY || secrets.OPENCODE_API_KEY }}
GH_APP_ID: ${{ secrets.GH_APP_ID || secrets.GITHUB_APP_ID }}
GH_APP_PRIVATE_KEY: ${{ secrets.GH_APP_PRIVATE_KEY || secrets.GITHUB_APP_PRIVATE_KEY }}
GH_APP_INSTALLATION_ID: ${{ secrets.GH_APP_INSTALLATION_ID || secrets.GITHUB_APP_INSTALLATION_ID }}
GOOSE_BASE_URL: ${{ inputs.goose_base_url || inputs.opencode_base_url }}
GOOSE_MODEL: ${{ inputs.goose_model || inputs.opencode_model }}
GOOSE_THINKING_EFFORT: ${{ inputs.goose_thinking_effort || inputs.opencode_reasoning_effort }}
GOOSE_VERSION: v1.46.0
REVIEW_POLICY: ${{ inputs.review_policy }}
REVIEW_STRICTNESS: ${{ inputs.review_strictness }}
REVIEW_INSTRUCTIONS: ${{ inputs.review_instructions }}
REVIEW_BRANCHES: ${{ inputs.review_branches }}
REPOSITORY_KNOWLEDGE_ENABLED: ${{ inputs.repository_knowledge_enabled }}
REPOSITORY_KNOWLEDGE_WRITE: ${{ inputs.repository_knowledge_write }}
R2_ENDPOINT: ${{ inputs.r2_endpoint }}
R2_BUCKET_NAME: ${{ inputs.r2_bucket_name }}
R2_PREFIX: ${{ inputs.r2_prefix }}
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
TRIAGE_ENABLED: ${{ inputs.triage_enabled }}
TRIAGE_LABELS: ${{ inputs.triage_labels }}
TRIAGE_DUPLICATE_LABEL: ${{ inputs.triage_duplicate_label }}
TRIAGE_CANDIDATE_LIMIT: ${{ inputs.triage_candidate_limit }}
TRIAGE_INSTRUCTIONS: ${{ inputs.triage_instructions }}
BOT_NAME: ${{ inputs.bot_name }}
AUTO_MERGE: ${{ inputs.auto_merge }}
AUTO_RESOLVE_CONFLICTS: ${{ inputs.auto_resolve_conflicts }}
CONFLICT_TEST_COMMAND: ${{ inputs.conflict_test_command }}
MERGE_METHOD: ${{ inputs.merge_method }}
REQUIRE_CHECKS: ${{ inputs.require_checks }}
MAX_PATCH_CHARS: ${{ inputs.max_patch_chars }}
GHBOT_RUNTIME_DIR: ${{ inputs.runtime_directory }}
LOG_LEVEL: ${{ inputs.log_level }}
GHBOT_EVENT_NAME: ${{ inputs.event_name }}
GHBOT_EVENT_ACTION: ${{ inputs.event_action }}
GHBOT_REPOSITORY_OWNER: ${{ inputs.repository_owner }}
GHBOT_REPOSITORY_NAME: ${{ inputs.repository_name }}
GHBOT_REPOSITORY_ID: ${{ inputs.repository_id }}
GHBOT_PULL_NUMBER: ${{ inputs.pull_number }}
GHBOT_PULL_HEAD_REPOSITORY: ${{ inputs.pull_head_repository }}
GHBOT_GOOSE_BINARY: ${{ runner.temp }}/goose/bin/goose
GHBOT_COMMENT_ID: ${{ inputs.comment_id }}
GHBOT_COMMENTER_LOGIN: ${{ inputs.commenter_login }}
GHBOT_COMMENT_BODY: ${{ inputs.comment_body }}
GHBOT_PR_WORKTREE: ${{ github.workspace }}/pr-worktree
GHBOT_REVIEWER_LOGIN: ${{ inputs.reviewer_login }}
GHBOT_REVIEW_STATE: ${{ inputs.review_state }}
GHBOT_REVIEW_COMMIT_ID: ${{ inputs.review_commit_id }}
schedule-recheck:
name: bot-schedule-recheck
if: ${{ inputs.run_schedule_recheck == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: lezi-fun/ghbot
ref: main
path: ghbot-runtime
- uses: actions/setup-node@v4
with:
node-version: 24
- name: Install goose CLI
env:
GOOSE_VERSION: v1.46.0
GOOSE_BIN_DIR: ${{ runner.temp }}/goose/bin
CONFIGURE: "false"
run: |
curl -fsSL "https://github.com/aaif-goose/goose/releases/download/${GOOSE_VERSION}/download_cli.sh" | bash
echo "${GOOSE_BIN_DIR}" >> "${GITHUB_PATH}"
- run: npm ci
working-directory: ghbot-runtime
- run: npm run build
working-directory: ghbot-runtime
- run: node dist/src/actions/runReview.js
working-directory: ghbot-runtime
env:
GITHUB_TOKEN: ${{ github.token }}
GOOSE_API_KEY: ${{ secrets.GOOSE_API_KEY || secrets.OPENCODE_API_KEY }}
GH_APP_ID: ${{ secrets.GH_APP_ID || secrets.GITHUB_APP_ID }}
GH_APP_PRIVATE_KEY: ${{ secrets.GH_APP_PRIVATE_KEY || secrets.GITHUB_APP_PRIVATE_KEY }}
GH_APP_INSTALLATION_ID: ${{ secrets.GH_APP_INSTALLATION_ID || secrets.GITHUB_APP_INSTALLATION_ID }}
GOOSE_BASE_URL: ${{ inputs.goose_base_url || inputs.opencode_base_url }}
GOOSE_MODEL: ${{ inputs.goose_model || inputs.opencode_model }}
GOOSE_THINKING_EFFORT: ${{ inputs.goose_thinking_effort || inputs.opencode_reasoning_effort }}
GOOSE_VERSION: v1.46.0
REVIEW_POLICY: ${{ inputs.review_policy }}
REVIEW_STRICTNESS: ${{ inputs.review_strictness }}
REVIEW_INSTRUCTIONS: ${{ inputs.review_instructions }}
REVIEW_BRANCHES: ${{ inputs.review_branches }}
REPOSITORY_KNOWLEDGE_ENABLED: ${{ inputs.repository_knowledge_enabled }}
REPOSITORY_KNOWLEDGE_WRITE: ${{ inputs.repository_knowledge_write }}
R2_ENDPOINT: ${{ inputs.r2_endpoint }}
R2_BUCKET_NAME: ${{ inputs.r2_bucket_name }}
R2_PREFIX: ${{ inputs.r2_prefix }}
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
TRIAGE_ENABLED: ${{ inputs.triage_enabled }}
TRIAGE_LABELS: ${{ inputs.triage_labels }}
TRIAGE_DUPLICATE_LABEL: ${{ inputs.triage_duplicate_label }}
TRIAGE_CANDIDATE_LIMIT: ${{ inputs.triage_candidate_limit }}
TRIAGE_INSTRUCTIONS: ${{ inputs.triage_instructions }}
BOT_NAME: ${{ inputs.bot_name }}
AUTO_MERGE: ${{ inputs.auto_merge }}
AUTO_RESOLVE_CONFLICTS: ${{ inputs.auto_resolve_conflicts }}
CONFLICT_TEST_COMMAND: ${{ inputs.conflict_test_command }}
MERGE_METHOD: ${{ inputs.merge_method }}
REQUIRE_CHECKS: ${{ inputs.require_checks }}
MAX_PATCH_CHARS: ${{ inputs.max_patch_chars }}
GHBOT_RUNTIME_DIR: ${{ inputs.runtime_directory }}
LOG_LEVEL: ${{ inputs.log_level }}
GHBOT_EVENT_NAME: schedule
GHBOT_EVENT_ACTION: schedule
GHBOT_REPOSITORY_OWNER: ${{ inputs.repository_owner }}
GHBOT_REPOSITORY_NAME: ${{ inputs.repository_name }}
GHBOT_REPOSITORY_ID: ${{ inputs.repository_id }}
GHBOT_PULL_NUMBER: "1"