Skip to content

Commit fc4c9db

Browse files
authored
feat: add auto-merge workflow for Snyk Bot pull requests
1 parent ddcecdd commit fc4c9db

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

.github/workflows/auto-merge.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Auto Merge Snyk Bot PRs
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
9+
10+
jobs:
11+
automerge:
12+
if: >
13+
github.actor == 'snyk-io[bot]' &&
14+
github.event.pull_request.head.repo.full_name == github.repository
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '20'
25+
26+
- name: Wait for all checks to pass
27+
uses: actions/github-script@v6
28+
with:
29+
script: |
30+
const pr = context.payload.pull_request;
31+
const checks = await github.checks.listForRef({
32+
owner: context.repo.owner,
33+
repo: context.repo.repo,
34+
ref: pr.head.sha,
35+
});
36+
if (checks.data.check_runs.some(check => check.conclusion !== 'success')) {
37+
core.setFailed('Not all checks have passed.');
38+
}
39+
40+
- name: Merge the pull request
41+
uses: actions/github-script@v6
42+
with:
43+
script: |
44+
await github.pulls.merge({
45+
owner: context.repo.owner,
46+
repo: context.repo.repo,
47+
pull_number: context.payload.pull_request.number,
48+
merge_method: 'squash',
49+
});

0 commit comments

Comments
 (0)