-
Notifications
You must be signed in to change notification settings - Fork 0
39 lines (38 loc) · 1.34 KB
/
automerge.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
name: "Automerge"
on:
workflow_run:
workflows:
- CI
types:
- completed
jobs:
Automerge:
runs-on: ubuntu-latest
if: |
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
steps:
- name: 'Merge PR'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.workflow_run.pull_requests[0].number,
});
if (!pr.data.title.startsWith('chore(deps-dev):')) {
console.log('Not Merged 🚫');
console.log(`Title '${pr.data.title}' does not start with 'chore(deps-dev):'`);
} else if (pr.data.user.login !== 'dependabot[bot]') {
console.log('Not Merged 🚫');
console.log(`User '${pr.data.user.login}' does not equal 'dependabot[bot]'`);
} else {
await github.rest.pulls.merge({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.workflow_run.pull_requests[0].number,
});
console.log('Merged 🎉');
}