Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
43 changes: 43 additions & 0 deletions .github/workflows/auto-approve.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Auto Approve PR

permissions:
pull-requests: write

on:
workflow_run:
workflows: ["Rocketmq Rust CI"]
types:
- completed

jobs:
auto-approve:
name: Auto Approve PR
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
steps:
- name: Get PR number
id: pr
uses: actions/github-script@v7
with:
script: |
const pulls = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: `${context.repo.owner}:${context.payload.workflow_run.head_branch}`
});

if (pulls.data.length > 0) {
return pulls.data[0].number;
}
return null;

- name: Auto approve PR
if: steps.pr.outputs.result != 'null'
uses: hmarr/auto-approve-action@v4
with:
github-token: ${{ secrets.BOT_TOKEN }}
pull-request-number: ${{ steps.pr.outputs.result }}
review-message: "LGTM - All CI checks passed ✅"
35 changes: 35 additions & 0 deletions .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Auto Merge PR

permissions:
contents: write
pull-requests: write

on:
workflow_run:
workflows: ["Auto Approve PR"]
types:
- completed

jobs:
auto-merge:
name: Auto Merge PR
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

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

The github.event.workflow_run.event property does not exist in the workflow_run context. When a workflow is triggered by workflow_run, the original event type is not available this way. This condition will likely never be true. Consider removing the github.event.workflow_run.event check or retrieving the PR context differently, similar to how it's done in the auto-approve workflow.

Suggested change
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
if: github.event.workflow_run.conclusion == 'success'

Copilot uses AI. Check for mistakes.
steps:
- name: Checkout code
uses: actions/checkout@v4

Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

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

The checkout step may be unnecessary for the pascalgn/automerge-action as it operates via the GitHub API and doesn't require the repository code. Consider removing this step unless it's required for a specific reason.

Suggested change
- name: Checkout code
uses: actions/checkout@v4

Copilot uses AI. Check for mistakes.
- name: Auto merge
uses: pascalgn/automerge-action@v0.16.4
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
MERGE_LABELS: "auto merge"
Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

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

The auto-merge workflow lacks logic to verify that the PR has the 'auto merge' label before attempting to merge. The original implementation in ci.yaml had contains(github.event.pull_request.labels.*.name, 'auto merge') in the if condition, but this check is missing in the new workflow. The MERGE_LABELS environment variable for pascalgn/automerge-action may not work correctly without proper PR context when triggered via workflow_run. Consider adding label verification using actions/github-script to fetch PR details and check for the label.

Copilot uses AI. Check for mistakes.
MERGE_METHOD: "squash"
MERGE_COMMIT_MESSAGE: "automatic"
MERGE_FORKS: "true"
MERGE_RETRIES: "50"
MERGE_RETRY_SLEEP: "10000"
MERGE_REQUIRED_APPROVALS: "1"
UPDATE_METHOD: "rebase"
41 changes: 1 addition & 40 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,43 +140,4 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
fail_ci_if_error: false
verbose: true

# Auto approve PR after all checks pass
auto-approve:
name: Auto Approve PR
runs-on: ubuntu-latest
needs: [ check, build-test, coverage ]
if: github.event_name == 'pull_request' && github.ref != 'refs/heads/main'
permissions:
pull-requests: write
steps:
- name: Auto approve PR
uses: hmarr/auto-approve-action@v4
with:
github-token: ${{ secrets.BOT_TOKEN }}
pull-request-number: ${{ github.event.pull_request.number }}
review-message: "LGTM - All CI checks passed ✅"

# Auto merge PR after approval
auto-merge:
name: Auto Merge PR
runs-on: ubuntu-latest
needs: [ auto-approve ]
if: github.event_name == 'pull_request' && github.ref != 'refs/heads/main' && contains(github.event.pull_request.labels.*.name, 'auto merge')
permissions:
contents: write
pull-requests: write
steps:
- name: Auto merge
uses: pascalgn/automerge-action@v0.16.4
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
MERGE_LABELS: "auto merge"
MERGE_METHOD: "squash"
MERGE_COMMIT_MESSAGE: "automatic"
MERGE_FORKS: "true"
MERGE_RETRIES: "50"
MERGE_RETRY_SLEEP: "10000"
MERGE_REQUIRED_APPROVALS: "1"
UPDATE_METHOD: "rebase"
verbose: true