Skip to content

Commit

Permalink
Only automerge PR if generated code updated
Browse files Browse the repository at this point in the history
  • Loading branch information
razor-x committed Apr 5, 2024
1 parent d0e7822 commit 9cffbe0
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 10 deletions.
20 changes: 12 additions & 8 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
---
version: 2
updates:
- package-ecosystem: 'npm'
- package-ecosystem: npm
directory: '/'
schedule:
interval: 'daily'
target-branch: 'main'
versioning-strategy: 'auto'
interval: daily
commit-message:
prefix: feat
include: scope
allow:
- dependency-name: '@seamapi/*'
dependency-type: 'development'
- dependency-type: development
ignore:
- dependency-name: '@seamapi/*'
update-types: ['version-update:semver-major']
- dependency-name: '*'
update-types:
- 'version-update:semver-major'
groups:
seam:
dependency-type: development
patterns:
- '@seamapi/*'
update-types:
- patch
- minor
49 changes: 47 additions & 2 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,45 @@ on:
- main

jobs:
merge:
name: Merge #${{ number }}
changes:
name: Get changes
runs-on: ubuntu-latest
timeout-minutes: 30
if: github.actor == 'dependabot[bot]'
permissions:
checks: read
outputs:
has_changes: ${{ steps.changed.outputs.any_changed == 'true' }}
is_generation_successful: ${{ steps.checks.outputs.conclusion == 'success' }}
steps:
- name: Wait for checks
uses: fountainhead/[email protected]
id: checks
with:
checkName: Generate code
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Get changed generated files
id: changed
uses: tj-actions/changed-files@v44
with:
files: |
seam/**
merge:
name: Merge
runs-on: ubuntu-latest
timeout-minutes: 30
needs: changes
if: needs.changes.outputs.has_changes == 'true'
steps:
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
files_separator: ' '
dir_names: true
dir_names_include_files: |
src/lib/seam/connect/routes/**
- name: Approve pull request
run: gh pr review --approve "$PR_URL"
env:
Expand All @@ -23,3 +56,15 @@ jobs:
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
close:
name: Close
runs-on: ubuntu-latest
timeout-minutes: 30
needs: changes
if: needs.changes.outputs.has_changes == 'false' && needs.changes.outputs.is_generation_successful == 'true'
steps:
- name: Close pull request
run: gh pr close "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}

0 comments on commit 9cffbe0

Please sign in to comment.