-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (58 loc) · 2.17 KB
/
dependabot-check.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
53
54
55
56
57
58
59
60
name: dependabot-check
on:
pull_request_target:
branches: [main]
paths:
- "go.sum"
- "go.mod"
permissions:
pull-requests: write
contents: write
jobs:
dependabot-auto-merge:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1.6.0
with:
github-token: '${{ secrets.GITHUB_TOKEN }}'
- uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const ret = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number
});
const currentLabels = ret.data.map(label => label.name);
const addLabels = ['change-category/dependency'];
if ('${{ steps.metadata.outputs.update-type }}' == 'version-update:semver-major') {
addLabels.push('change-category/breaking');
}
const labels = currentLabels.concat(addLabels);
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels
});
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Approve if PR is patch update
if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-patch' }}
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Approve if PR is minor update
if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-minor' }}
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}