Skip to content

Commit 446b276

Browse files
committed
Only automerge PR if generated code updated
1 parent d0e7822 commit 446b276

File tree

2 files changed

+51
-10
lines changed

2 files changed

+51
-10
lines changed

.github/dependabot.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1+
---
12
version: 2
23
updates:
3-
- package-ecosystem: 'npm'
4+
- package-ecosystem: npm
45
directory: '/'
56
schedule:
6-
interval: 'daily'
7-
target-branch: 'main'
8-
versioning-strategy: 'auto'
7+
interval: daily
8+
commit-message:
9+
prefix: feat
10+
include: scope
911
allow:
10-
- dependency-name: '@seamapi/*'
11-
dependency-type: 'development'
12+
- dependency-type: development
1213
ignore:
13-
- dependency-name: '@seamapi/*'
14-
update-types: ['version-update:semver-major']
14+
- dependency-name: '*'
15+
update-types:
16+
- 'version-update:semver-major'
1517
groups:
1618
seam:
1719
dependency-type: development
20+
patterns:
21+
- '@seamapi/*'
1822
update-types:
1923
- patch
2024
- minor

.github/workflows/automerge.yml

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,36 @@ on:
77
- main
88

99
jobs:
10-
merge:
11-
name: Merge #${{ number }}
10+
changes:
11+
name: Get changes
1212
runs-on: ubuntu-latest
1313
timeout-minutes: 30
1414
if: github.actor == 'dependabot[bot]'
15+
permissions:
16+
checks: read
17+
outputs:
18+
has_changes: ${{ steps.changed.outputs.any_changed == 'true' }}
19+
is_generation_successful: ${{ steps.checks.outputs.conclusion == 'success' }}
20+
steps:
21+
- name: Wait for checks
22+
uses: fountainhead/action-wait-for-check@v1.2.0
23+
id: checks
24+
with:
25+
checkName: Generate code
26+
ref: ${{ github.event.pull_request.head.sha }}
27+
token: ${{ secrets.GITHUB_TOKEN }}
28+
- name: Get changed generated files
29+
id: changed
30+
uses: tj-actions/changed-files@v44
31+
with:
32+
files: |
33+
seam/**
34+
merge:
35+
name: Merge
36+
runs-on: ubuntu-latest
37+
timeout-minutes: 30
38+
needs: changes
39+
if: needs.changes.outputs.has_changes == 'true'
1540
steps:
1641
- name: Approve pull request
1742
run: gh pr review --approve "$PR_URL"
@@ -23,3 +48,15 @@ jobs:
2348
env:
2449
PR_URL: ${{ github.event.pull_request.html_url }}
2550
GH_TOKEN: ${{ secrets.GH_TOKEN }}
51+
close:
52+
name: Close
53+
runs-on: ubuntu-latest
54+
timeout-minutes: 30
55+
needs: changes
56+
if: needs.changes.outputs.has_changes == 'false' && needs.changes.outputs.is_generation_successful == 'true'
57+
steps:
58+
- name: Close pull request
59+
run: gh pr close "$PR_URL"
60+
env:
61+
PR_URL: ${{ github.event.pull_request.html_url }}
62+
GH_TOKEN: ${{ secrets.GH_TOKEN }}

0 commit comments

Comments
 (0)