-
Notifications
You must be signed in to change notification settings - Fork 1
45 lines (38 loc) · 1.25 KB
/
PR.yml
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
name: Merge on Checks Pass
on:
pull_request:
types:
- synchronize
- opened
- reopened
jobs:
merge:
runs-on: ubuntu-latest
steps:
- name: Wait for 30 seconds
run: sleep 30
- name: Check GitHub Checks status
id: checks
uses: actions/github-script@v4
with:
script: |
const response = await github.pulls.listReviews({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number
});
const checks = response.data.filter(review => review.state === 'APPROVED');
return {
checks: checks,
isReadyToMerge: checks.length > 0
};
- name: Merge PR if checks pass
if: ${{ steps.checks.outputs.isReadyToMerge }}
run: |
echo "All checks passed. Merging pull request..."
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git checkout -b merge-branch ${{ github.event.before }}
git merge --no-ff ${{ github.event.after }}
git push origin merge-branch
gh pr merge ${{ github.event.number }} --squash --auto