Skip to content

Commit f142e5b

Browse files
Update dependabot reviewer
1 parent a8e7fb9 commit f142e5b

File tree

1 file changed

+31
-23
lines changed

1 file changed

+31
-23
lines changed
Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,50 @@
11
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#approve-a-pull-request
2+
# https://nicolasiensen.github.io/2022-07-23-automating-dependency-updates-with-dependabot-github-auto-merge-and-github-actions/
23

34
name: auto_merge
4-
on: # pull_request, push, workflow_dispatch
5+
6+
on: # pull_request, pull_request_target, push, workflow_dispatch
57
pull_request:
8+
pull_request_target:
69
workflow_dispatch:
710
push:
811
release:
912
types: [published]
1013

1114
permissions:
1215
pull-requests: write
16+
contents: write
1317

1418
jobs:
15-
dependabot:
19+
review-dependabot-pr:
1620
runs-on: ubuntu-latest
17-
if: ${{ github.actor == 'dependabot[bot]' }}
21+
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
1822
steps:
1923
- name: Dependabot metadata
20-
id: metadata
21-
uses: dependabot/fetch-metadata@v1.1.1
22-
with:
23-
github-token: "${{ secrets.GITHUB_TOKEN }}"
24-
- name: Approve a PR
25-
run: gh pr review --approve "$PR_URL"
24+
id: dependabot-metadata
25+
uses: dependabot/fetch-metadata@v1.3.1
26+
- name: Enable auto-merge for Dependabot PRs
27+
run: gh pr merge --auto --merge "$PR_URL"
2628
env:
27-
PR_URL: ${{ github.event.pull_request.html_url }}
28-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29-
- name: Merge a PR
30-
run: gh pr merge "$PR_URL" --auto --squash
29+
PR_URL: ${{github.event.pull_request.html_url}}
30+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
31+
- name: Approve patch and minor updates
32+
if: ${{steps.dependabot-metadata.outputs.update-type == 'version-update:semver-patch' || steps.dependabot-metadata.outputs.update-type == 'version-update:semver-minor'}}
33+
run: gh pr review $PR_URL --approve -b "I'm **approving** this pull request because **it includes a patch or minor update**"
3134
env:
32-
PR_URL: ${{ github.event.pull_request.html_url }}
33-
auto-rebase:
34-
name: rebase dependabot PRs
35-
runs-on: ubuntu-latest
36-
if: github.ref == 'refs/heads/main' || github.event == 'release'
37-
timeout-minutes: 5
38-
steps:
39-
- name: rebase
40-
uses: "bbeesley/gha-auto-dependabot-rebase@main"
35+
PR_URL: ${{github.event.pull_request.html_url}}
36+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
37+
- name: Approve major updates of development dependencies
38+
if: ${{steps.dependabot-metadata.outputs.update-type == 'version-update:semver-major' && steps.dependabot-metadata.outputs.dependency-type == 'direct:development'}}
39+
run: gh pr review $PR_URL --approve -b "I'm **approving** this pull request because **it includes a major update of a dependency used only in development**"
40+
env:
41+
PR_URL: ${{github.event.pull_request.html_url}}
42+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
43+
- name: Comment on major updates of non-development dependencies
44+
if: ${{steps.dependabot-metadata.outputs.update-type == 'version-update:semver-major' && steps.dependabot-metadata.outputs.dependency-type == 'direct:production'}}
45+
run: |
46+
gh pr comment $PR_URL --body "I'm **not approving** this PR because **it includes a major update of a dependency used in production**"
47+
gh pr edit $PR_URL --add-label "requires-manual-qa"
4148
env:
42-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
PR_URL: ${{github.event.pull_request.html_url}}
50+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

0 commit comments

Comments
 (0)