Skip to content

Commit f4fbcae

Browse files
Merge pull request #211 from NHSDigital/mesh-2092-create-automerge-workflow
mesh-2092: add auto merge workflow
2 parents cf7e25b + 3acc65f commit f4fbcae

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Auto-merge Dependabot PRs
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
- ready_for_review
10+
- labeled
11+
12+
jobs:
13+
dependabot-make-update:
14+
# Only run on Dependabot PRs
15+
if: github.event.pull_request.user.login == 'dependabot[bot]'
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Install Python 3.11
25+
uses: actions/setup-python@v4
26+
with:
27+
python-version: '3.11'
28+
29+
- name: Install poetry
30+
run: python -m pip install --upgrade pip setuptools wheel poetry
31+
32+
- name: Install project dependencies
33+
run: make install-ci
34+
35+
- name: Update dependencies (make update)
36+
run: make update
37+
38+
- name: Lint (make lint)
39+
run: make lint
40+
41+
enable-automerge:
42+
# Only run on Dependabot PRs after make update succeeds
43+
if: github.event.pull_request.user.login == 'dependabot[bot]'
44+
needs: dependabot-make-update
45+
runs-on: ubuntu-latest
46+
permissions:
47+
contents: write
48+
pull-requests: write
49+
50+
steps:
51+
- name: Fetch Dependabot metadata
52+
id: metadata
53+
uses: dependabot/fetch-metadata@d7267f607e9d3fb96fc2fbe83e0af444713e90b7
54+
with:
55+
github-token: ${{ secrets.GITHUB_TOKEN }}
56+
57+
- name: Enable auto-merge for Dependabot PRs
58+
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
59+
run: gh pr merge --auto --squash "$PR_URL"
60+
env:
61+
PR_URL: ${{ github.event.pull_request.html_url }}
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)