-
Notifications
You must be signed in to change notification settings - Fork 129
66 lines (57 loc) · 2.06 KB
/
Copy pathpr-automerge.yml
File metadata and controls
66 lines (57 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: PR Auto-merge
on:
pull_request_review:
types: [submitted]
permissions:
contents: write
pull-requests: write
jobs:
auto-merge:
name: Auto-merge Release PRs
runs-on: ubuntu-latest
# Only run when PR is approved and it's a release PR
if: |
github.event.review.state == 'approved' &&
github.event.pull_request.user.login == 'github-actions[bot]' &&
startsWith(github.event.pull_request.head.ref, 'release/') &&
github.event.pull_request.base.ref == 'main'
steps:
- name: Check CI status
id: ci-status
uses: actions/github-script@v8
with:
script: |
const { data: checkRuns } = await github.rest.checks.listForRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: context.payload.pull_request.head.sha
});
// Include ALL required checks
const requiredChecks = [
'Lint',
'Test Python 3.10',
'Test Python 3.11',
'Test Python 3.12',
'Test Python 3.13',
'Build Package'
];
const allPassed = requiredChecks.every(checkName => {
const check = checkRuns.check_runs.find(run => run.name === checkName);
return check && check.conclusion === 'success';
});
console.log(`All required checks passed: ${allPassed}`);
return allPassed;
- name: Auto-merge PR
if: steps.ci-status.outputs.result == 'true'
uses: actions/github-script@v8
with:
script: |
await github.rest.pulls.merge({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
merge_method: 'squash',
commit_title: `Release v${context.payload.pull_request.head.ref.split('/')[1]}`,
commit_message: 'Auto-merged by release workflow'
});
console.log('✓ PR auto-merged successfully');