-
Notifications
You must be signed in to change notification settings - Fork 1
52 lines (47 loc) · 1.54 KB
/
dependabot.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
49
50
51
52
name: 'Dependabot'
on:
pull_request_target:
branches: [main]
permissions:
contents: read
pull-requests: write
jobs:
autoapprove:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
name: Autoapprove
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Autoapprove
uses: actions/github-script@v4
with:
script: |
const owner = context.payload.repository.owner.login;
const repo = context.payload.repository.name;
const pull_number = context.payload.pull_request.number;
github.pulls
.listReviews({ owner, repo, pull_number })
.then((response) =>
response.data
.filter(r => r.state == 'APPROVED')
.filter(r => r.user.login = 'github-actions[bot]')
)
.then((approvals) => {
if (approvals.length !== 0) {
console.log('I already approved this PR! :)');
return;
}
// Approve and leave a comment for the human reviewer.
const body =
'Dear human reviewer, copy and paste this to auto merge: \n' +
'@dependabot squash and merge';
const event = 'APPROVE';
return github.pulls.createReview({
owner,
repo,
pull_number,
body,
event,
});
});