-
Notifications
You must be signed in to change notification settings - Fork 56
48 lines (48 loc) · 1.69 KB
/
auto-merge.yaml
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: auto-merge
on:
pull_request:
permissions:
contents: write
pull-requests: write
jobs:
check-can-auto-merge:
if: github.triggering_actor == 'dependabot[bot]'
name: Check if PR can be auto-merged
runs-on: ubuntu-latest
outputs:
can-auto-merge: ${{ steps.can-auto-merge.outputs.approve }}
steps:
- uses: dependabot/[email protected]
id: dependabot-metadata
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- if: |
steps.dependabot-metadata.outputs.update-type == 'version-update:semver-patch' ||
steps.dependabot-metadata.outputs.package-ecosystem == 'github_actions'
id: can-auto-merge
run: echo "approve=true" >> $GITHUB_OUTPUT
auto-merge:
needs: check-can-auto-merge
if: needs.check-can-auto-merge.outputs.can-auto-merge == 'true'
name: Auto merge pull requests
runs-on: ubuntu-latest
steps:
- uses: dependabot/[email protected]
id: dependabot-metadata
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Approve Dependabot PR
run: gh pr review --approve "${PR_URL}"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
# Because we enforce PRs be approved by a code owner, a token from the
# operations team must be used to approve the PR. This token is from the
# StatusCake machine account which has been given membership to the
# operations team.
GITHUB_TOKEN: ${{ secrets.MACHINE_TOKEN }}
- name: Enable auto-merge for Dependabot PR
run: gh pr merge --auto --merge "${PR_URL}"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}