Migrate review automation to OpenCode
This commit is contained in:
1 parent
27db22cd78
commit
8aaecb4dc7
21 files changed
+2703
-713
No files matched your search
@@ -15,9 +15,17 @@ on:
|
||||
repository_name:
|
||||
required: true
|
||||
type: string
|
||||
repository_id:
|
||||
required: false
|
||||
type: string
|
||||
default: ""
|
||||
pull_number:
|
||||
required: true
|
||||
type: string
|
||||
comment_id:
|
||||
required: false
|
||||
type: string
|
||||
default: ""
|
||||
commenter_login:
|
||||
required: false
|
||||
type: string
|
||||
@@ -42,18 +50,50 @@ on:
|
||||
required: false
|
||||
type: string
|
||||
default: github-actions[bot]
|
||||
codex_base_url:
|
||||
opencode_base_url:
|
||||
required: false
|
||||
type: string
|
||||
default: https://api.openai.com/v1
|
||||
codex_model:
|
||||
opencode_model:
|
||||
required: false
|
||||
type: string
|
||||
default: gpt-5.4
|
||||
codex_reasoning_effort:
|
||||
opencode_reasoning_effort:
|
||||
required: false
|
||||
type: string
|
||||
default: high
|
||||
review_policy:
|
||||
required: false
|
||||
type: string
|
||||
default: require_approval
|
||||
review_instructions:
|
||||
required: false
|
||||
type: string
|
||||
default: ""
|
||||
review_branches:
|
||||
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
|
||||
@@ -79,7 +119,7 @@ on:
|
||||
type: string
|
||||
default: "false"
|
||||
secrets:
|
||||
CODEX_API_KEY:
|
||||
OPENCODE_API_KEY:
|
||||
required: true
|
||||
GH_APP_ID:
|
||||
required: false
|
||||
@@ -95,6 +135,7 @@ on:
|
||||
required: false
|
||||
|
||||
permissions:
|
||||
actions: write
|
||||
contents: write
|
||||
pull-requests: write
|
||||
checks: write
|
||||
@@ -112,31 +153,53 @@ jobs:
|
||||
repository: lezi-fun/ghbot
|
||||
ref: main
|
||||
path: ghbot-runtime
|
||||
- name: Check out current PR source for comment chat
|
||||
if: ${{ inputs.event_name == 'issue_comment' }}
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ inputs.repository_owner }}/${{ inputs.repository_name }}
|
||||
ref: refs/pull/${{ inputs.pull_number }}/head
|
||||
path: pr-worktree
|
||||
fetch-depth: 1
|
||||
persist-credentials: false
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 24
|
||||
cache: npm
|
||||
cache-dependency-path: ghbot-runtime/package-lock.json
|
||||
- name: Install Codex CLI
|
||||
run: npm install -g @openai/codex
|
||||
- name: Install OpenCode CLI
|
||||
run: npm install -g opencode-ai@1.18.14
|
||||
- run: npm ci
|
||||
working-directory: ghbot-runtime
|
||||
- run: npm run build
|
||||
working-directory: ghbot-runtime
|
||||
- name: Remove stale review result
|
||||
run: rm -f .review-result.json
|
||||
working-directory: ghbot-runtime
|
||||
- name: Restore previous PR review
|
||||
if: ${{ inputs.event_name == 'pull_request_target' && inputs.event_action != 'closed' }}
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ghbot-runtime/.ghbot-cache/pr-${{ inputs.pull_number }}.json
|
||||
key: ghbot-review-${{ github.repository_id }}-pr-${{ inputs.pull_number }}-${{ github.run_id }}
|
||||
restore-keys: |
|
||||
ghbot-review-${{ github.repository_id }}-pr-${{ inputs.pull_number }}-
|
||||
- run: node dist/src/actions/runReview.js
|
||||
working-directory: ghbot-runtime
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
CODEX_API_KEY: ${{ secrets.CODEX_API_KEY }}
|
||||
OPENCODE_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 }}
|
||||
CODEX_BASE_URL: ${{ inputs.codex_base_url }}
|
||||
CODEX_MODEL: ${{ inputs.codex_model }}
|
||||
CODEX_REASONING_EFFORT: ${{ inputs.codex_reasoning_effort }}
|
||||
OPENCODE_BASE_URL: ${{ inputs.opencode_base_url }}
|
||||
OPENCODE_MODEL: ${{ inputs.opencode_model }}
|
||||
OPENCODE_REASONING_EFFORT: ${{ inputs.opencode_reasoning_effort }}
|
||||
REVIEW_POLICY: ${{ inputs.review_policy }}
|
||||
REVIEW_INSTRUCTIONS: ${{ inputs.review_instructions }}
|
||||
REVIEW_BRANCHES: ${{ inputs.review_branches }}
|
||||
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 }}
|
||||
MERGE_METHOD: ${{ inputs.merge_method }}
|
||||
@@ -147,9 +210,12 @@ jobs:
|
||||
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_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 }}
|
||||
@@ -168,26 +234,31 @@ jobs:
|
||||
node-version: 24
|
||||
cache: npm
|
||||
cache-dependency-path: ghbot-runtime/package-lock.json
|
||||
- name: Install Codex CLI
|
||||
run: npm install -g @openai/codex
|
||||
- name: Install OpenCode CLI
|
||||
run: npm install -g opencode-ai@1.18.14
|
||||
- run: npm ci
|
||||
working-directory: ghbot-runtime
|
||||
- run: npm run build
|
||||
working-directory: ghbot-runtime
|
||||
- name: Remove stale review result
|
||||
run: rm -f .review-result.json
|
||||
working-directory: ghbot-runtime
|
||||
- run: node dist/src/actions/runReview.js
|
||||
working-directory: ghbot-runtime
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
CODEX_API_KEY: ${{ secrets.CODEX_API_KEY }}
|
||||
OPENCODE_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 }}
|
||||
CODEX_BASE_URL: ${{ inputs.codex_base_url }}
|
||||
CODEX_MODEL: ${{ inputs.codex_model }}
|
||||
CODEX_REASONING_EFFORT: ${{ inputs.codex_reasoning_effort }}
|
||||
OPENCODE_BASE_URL: ${{ inputs.opencode_base_url }}
|
||||
OPENCODE_MODEL: ${{ inputs.opencode_model }}
|
||||
OPENCODE_REASONING_EFFORT: ${{ inputs.opencode_reasoning_effort }}
|
||||
REVIEW_POLICY: ${{ inputs.review_policy }}
|
||||
REVIEW_INSTRUCTIONS: ${{ inputs.review_instructions }}
|
||||
REVIEW_BRANCHES: ${{ inputs.review_branches }}
|
||||
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 }}
|
||||
MERGE_METHOD: ${{ inputs.merge_method }}
|
||||
@@ -198,4 +269,5 @@ jobs:
|
||||
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"
|
||||
@@ -7,6 +7,13 @@ on:
|
||||
- synchronize
|
||||
- reopened
|
||||
- ready_for_review
|
||||
- edited
|
||||
- closed
|
||||
issues:
|
||||
types:
|
||||
- opened
|
||||
- edited
|
||||
- reopened
|
||||
issue_comment:
|
||||
types:
|
||||
- created
|
||||
@@ -17,6 +24,7 @@ on:
|
||||
- cron: "17 * * * *"
|
||||
|
||||
permissions:
|
||||
actions: write
|
||||
contents: write
|
||||
pull-requests: write
|
||||
checks: write
|
||||
@@ -27,11 +35,12 @@ jobs:
|
||||
review:
|
||||
if: |
|
||||
github.event_name == 'pull_request_target' ||
|
||||
github.event_name == 'issues' ||
|
||||
(github.event_name == 'issue_comment' && github.event.issue.pull_request != null) ||
|
||||
github.event_name == 'pull_request_review'
|
||||
uses: ./.github/workflows/review-reusable.yml
|
||||
secrets:
|
||||
CODEX_API_KEY: ${{ secrets.CODEX_API_KEY }}
|
||||
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
|
||||
GH_APP_ID: ${{ secrets.GH_APP_ID }}
|
||||
GH_APP_PRIVATE_KEY: ${{ secrets.GH_APP_PRIVATE_KEY }}
|
||||
GH_APP_INSTALLATION_ID: ${{ secrets.GH_APP_INSTALLATION_ID }}
|
||||
@@ -40,16 +49,26 @@ jobs:
|
||||
event_action: ${{ github.event.action }}
|
||||
repository_owner: ${{ github.repository_owner }}
|
||||
repository_name: ${{ github.event.repository.name }}
|
||||
repository_id: ${{ github.repository_id }}
|
||||
pull_number: ${{ github.event.pull_request.number || github.event.issue.number }}
|
||||
comment_id: ${{ github.event.comment.id || '' }}
|
||||
commenter_login: ${{ github.event.comment.user.login || '' }}
|
||||
comment_body: ${{ github.event.comment.body || '' }}
|
||||
reviewer_login: ${{ github.event.review.user.login || '' }}
|
||||
review_state: ${{ github.event.review.state || '' }}
|
||||
review_commit_id: ${{ github.event.review.commit_id || '' }}
|
||||
bot_name: github-actions[bot]
|
||||
codex_base_url: ${{ vars.CODEX_BASE_URL || 'https://api.openai.com/v1' }}
|
||||
codex_model: ${{ vars.CODEX_MODEL || 'gpt-5.4' }}
|
||||
codex_reasoning_effort: ${{ vars.CODEX_REASONING_EFFORT || 'high' }}
|
||||
opencode_base_url: ${{ vars.OPENCODE_BASE_URL || 'https://api.openai.com/v1' }}
|
||||
opencode_model: ${{ vars.OPENCODE_MODEL || 'gpt-5.4' }}
|
||||
opencode_reasoning_effort: ${{ vars.OPENCODE_REASONING_EFFORT || 'high' }}
|
||||
review_policy: ${{ vars.REVIEW_POLICY || 'require_approval' }}
|
||||
review_instructions: ${{ vars.REVIEW_INSTRUCTIONS || '' }}
|
||||
review_branches: ${{ vars.REVIEW_BRANCHES || '' }}
|
||||
triage_enabled: ${{ vars.TRIAGE_ENABLED || 'true' }}
|
||||
triage_labels: ${{ vars.TRIAGE_LABELS || 'bug,enhancement,documentation,question,maintenance' }}
|
||||
triage_duplicate_label: ${{ vars.TRIAGE_DUPLICATE_LABEL || 'duplicate' }}
|
||||
triage_candidate_limit: ${{ vars.TRIAGE_CANDIDATE_LIMIT || '50' }}
|
||||
triage_instructions: ${{ vars.TRIAGE_INSTRUCTIONS || '' }}
|
||||
auto_merge: ${{ vars.AUTO_MERGE || 'false' }}
|
||||
merge_method: ${{ vars.MERGE_METHOD || 'squash' }}
|
||||
require_checks: ${{ vars.REQUIRE_CHECKS || 'true' }}
|
||||
@@ -59,7 +78,7 @@ jobs:
|
||||
if: github.event_name == 'schedule'
|
||||
uses: ./.github/workflows/review-reusable.yml
|
||||
secrets:
|
||||
CODEX_API_KEY: ${{ secrets.CODEX_API_KEY }}
|
||||
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
|
||||
GH_APP_ID: ${{ secrets.GH_APP_ID }}
|
||||
GH_APP_PRIVATE_KEY: ${{ secrets.GH_APP_PRIVATE_KEY }}
|
||||
GH_APP_INSTALLATION_ID: ${{ secrets.GH_APP_INSTALLATION_ID }}
|
||||
@@ -68,11 +87,20 @@ jobs:
|
||||
event_action: schedule
|
||||
repository_owner: ${{ github.repository_owner }}
|
||||
repository_name: ${{ github.event.repository.name }}
|
||||
repository_id: ${{ github.repository_id }}
|
||||
pull_number: "1"
|
||||
bot_name: github-actions[bot]
|
||||
codex_base_url: ${{ vars.CODEX_BASE_URL || 'https://api.openai.com/v1' }}
|
||||
codex_model: ${{ vars.CODEX_MODEL || 'gpt-5.4' }}
|
||||
codex_reasoning_effort: ${{ vars.CODEX_REASONING_EFFORT || 'high' }}
|
||||
opencode_base_url: ${{ vars.OPENCODE_BASE_URL || 'https://api.openai.com/v1' }}
|
||||
opencode_model: ${{ vars.OPENCODE_MODEL || 'gpt-5.4' }}
|
||||
opencode_reasoning_effort: ${{ vars.OPENCODE_REASONING_EFFORT || 'high' }}
|
||||
review_policy: ${{ vars.REVIEW_POLICY || 'require_approval' }}
|
||||
review_instructions: ${{ vars.REVIEW_INSTRUCTIONS || '' }}
|
||||
review_branches: ${{ vars.REVIEW_BRANCHES || '' }}
|
||||
triage_enabled: ${{ vars.TRIAGE_ENABLED || 'true' }}
|
||||
triage_labels: ${{ vars.TRIAGE_LABELS || 'bug,enhancement,documentation,question,maintenance' }}
|
||||
triage_duplicate_label: ${{ vars.TRIAGE_DUPLICATE_LABEL || 'duplicate' }}
|
||||
triage_candidate_limit: ${{ vars.TRIAGE_CANDIDATE_LIMIT || '50' }}
|
||||
triage_instructions: ${{ vars.TRIAGE_INSTRUCTIONS || '' }}
|
||||
auto_merge: ${{ vars.AUTO_MERGE || 'false' }}
|
||||
merge_method: ${{ vars.MERGE_METHOD || 'squash' }}
|
||||
require_checks: ${{ vars.REQUIRE_CHECKS || 'true' }}
|
||||
|
||||
Reference in new issue
Block a user