-
Notifications
You must be signed in to change notification settings - Fork 3
48 lines (41 loc) · 1.26 KB
/
dependabot-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
40
41
42
43
44
45
46
47
48
name: Dependabot Auto Merge
on:
pull_request:
types:
- synchronize
- reopened
- opened
jobs:
automerge:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install dependencies
run: npm install
- name: Run tests
run: npm test
- name: Debug Environment Variables
run: env
- name: Merge Dependabot PR
if: success()
uses: actions/github-script@v4
with:
script: |
const { context, github } = require('@actions/github');
const pr = context.payload.pull_request;
if (pr.user.login === 'dependabot[bot]' && pr.mergeable_state === 'clean') {
await github.pulls.merge({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
merge_method: 'squash'
});
} else {
console.log(`PR not mergeable or not from dependabot: user=${pr.user.login}, mergeable_state=${pr.mergeable_state}`);
}