File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Adapted from https://blog.somewhatabstract.com/2021/10/11/setting-up-dependabot-with-github-actions-to-approve-and-merge/
2
+ name : Dependabot auto-merge
3
+
4
+ on : pull_request
5
+
6
+ permissions :
7
+ pull-requests : write
8
+ contents : write
9
+
10
+ jobs :
11
+ dependabot :
12
+ runs-on : ubuntu-latest
13
+ # Checking the actor will prevent your Action run failing on non-Dependabot
14
+ # PRs but also ensures that it only does work for Dependabot PRs.
15
+ if : ${{ github.actor == 'dependabot[bot]' }}
16
+ steps :
17
+ # This first step will fail if there's no metadata and so the approval
18
+ # will not occur.
19
+ - name : Dependabot metadata
20
+ id : dependabot-metadata
21
+ uses : dependabot/fetch-metadata@v1
22
+ with :
23
+ github-token : " ${{ secrets.GITHUB_TOKEN }}"
24
+
25
+ # Here the PR gets approved.
26
+ - name : Approve a PR
27
+ if : ${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' }}
28
+ run : gh pr review --approve "${{ github.event.pull_request.html_url }}"
29
+ env :
30
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
31
+
32
+ # Finally, this sets the PR to allow auto-merging for patch and minor
33
+ # updates if all checks pass
34
+ - name : Enable auto-merge for Dependabot PRs
35
+ if : ${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' }}
36
+ run : gh pr merge --auto --squash "${{ github.event.pull_request.html_url }}"
37
+ env :
38
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
You can’t perform that action at this time.
0 commit comments