Skip to content

Commit fe588d1

Browse files
committed
[ISSUE #4291]♻️Refactor CI workflows to separate auto-approve and auto-merge actions for improved clarity and maintainability
1 parent c2a5095 commit fe588d1

File tree

2 files changed

+39
-49
lines changed

2 files changed

+39
-49
lines changed

.github/workflows/auto-approve.yml

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,34 @@
1-
name: Auto Approve PR
2-
3-
permissions:
4-
pull-requests: write
1+
name: Auto Approve Pull Requests
52

63
on:
7-
workflow_run:
8-
workflows: ["Rocketmq Rust CI"]
9-
types:
10-
- completed
4+
pull_request_target:
5+
types: [ labeled, opened, synchronize, reopened ]
6+
7+
permissions:
8+
pull-requests: read
9+
contents: read
10+
checks: read
1111

1212
jobs:
1313
auto-approve:
14-
name: Auto Approve PR
1514
runs-on: ubuntu-latest
1615
if: >
17-
github.event.workflow_run.event == 'pull_request' &&
18-
github.event.workflow_run.conclusion == 'success'
16+
github.event.pull_request.merged == false &&
17+
contains(github.event.pull_request.labels.*.name, 'auto merge')
18+
1919
steps:
20-
- name: Get PR number
21-
id: pr
22-
uses: actions/github-script@v7
20+
- name: Wait for Rocketmq Rust CI to succeed
21+
uses: lewagon/wait-on-check-action@v1.1.0
2322
with:
24-
script: |
25-
const pulls = await github.rest.pulls.list({
26-
owner: context.repo.owner,
27-
repo: context.repo.repo,
28-
state: 'open',
29-
head: `${context.repo.owner}:${context.payload.workflow_run.head_branch}`
30-
});
31-
32-
if (pulls.data.length > 0) {
33-
return pulls.data[0].number;
34-
}
35-
return null;
23+
token: ${{ secrets.GITHUB_TOKEN }}
24+
ref: ${{ github.event.pull_request.head.sha }}
25+
repo: ${{ github.repository }}
26+
wait-interval: 20
27+
running-workflow-name: "Rocketmq Rust CI"
3628

3729
- name: Auto approve PR
38-
if: steps.pr.outputs.result != 'null'
3930
uses: hmarr/auto-approve-action@v4
4031
with:
4132
github-token: ${{ secrets.BOT_TOKEN }}
42-
pull-request-number: ${{ steps.pr.outputs.result }}
43-
review-message: "LGTM - All CI checks passed"
33+
pull-request-number: ${{ github.event.pull_request.number }}
34+
review-message: "LGTMAll required checks passed. Auto-approved for merge."

.github/workflows/auto-merge.yml

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
11
name: Auto Merge PR
2-
3-
permissions:
4-
contents: write
5-
pull-requests: write
6-
72
on:
8-
workflow_run:
9-
workflows: ["Auto Approve PR"]
3+
pull_request:
4+
types:
5+
- labeled
6+
- unlabeled
7+
- synchronize
8+
- opened
9+
pull_request_review:
10+
types:
11+
- submitted
12+
check_suite:
1013
types:
1114
- completed
12-
15+
status: { }
1316
jobs:
14-
auto-merge:
15-
name: Auto Merge PR
17+
automerge:
1618
runs-on: ubuntu-latest
17-
if: >
18-
github.event.workflow_run.event == 'pull_request' &&
19-
github.event.workflow_run.conclusion == 'success'
19+
permissions:
20+
contents: write
21+
pull-requests: write
2022
steps:
21-
- name: Checkout code
22-
uses: actions/checkout@v4
23-
24-
- name: Auto merge
25-
uses: pascalgn/automerge-action@v0.16.4
23+
- name: automerge
24+
uses: "pascalgn/automerge-action@v0.16.4"
2625
env:
27-
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
26+
GITHUB_TOKEN: "${{ secrets.BOT_TOKEN }}"
2827
MERGE_LABELS: "auto merge"
2928
MERGE_METHOD: "squash"
3029
MERGE_COMMIT_MESSAGE: "automatic"
3130
MERGE_FORKS: "true"
3231
MERGE_RETRIES: "50"
3332
MERGE_RETRY_SLEEP: "10000"
3433
MERGE_REQUIRED_APPROVALS: "1"
35-
UPDATE_METHOD: "rebase"
34+
UPDATE_METHOD: "rebase"

0 commit comments

Comments
 (0)