Skip to content

Commit

Permalink
Add auto-merge workflows for pull requests
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonfire1119 committed Apr 28, 2024
1 parent cc24a87 commit dfd43f7
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: automerge
on:
pull_request:
types:
- labeled
- unlabeled
- synchronize
- opened
- edited
- ready_for_review
- reopened
- unlocked
pull_request_review:
types:
- submitted
check_suite:
types:
- completed
status: {}
jobs:
automerge:
env:
MERGE_METHOD: "squash"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
runs-on: ubuntu-latest
steps:
- id: automerge
name: automerge
uses: "pascalgn/[email protected]"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
43 changes: 43 additions & 0 deletions .github/workflows/renovate-automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Renovate AutoMerge

on:
pull_request:

jobs:
automerge:
if: contains(github.head_ref, 'renovate/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Analyze PR for Major Version Bump
id: analyze
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const body = context.payload.pull_request.body;
// Regex to find markdown table rows and check if any have 'major' in the Update column
const regex = /(?<=\|\s\[)(?:[^\]]+\]\(https?:\/\/[^\s\)]+\)\s\|\s)(major)(?=\s\|)/gi;
const isMajorUpdate = regex.test(body);
if (isMajorUpdate) {
console.log("Found a major version bump.");
core.setOutput("automerge", "false");
} else {
console.log("No major version bump found.");
core.setOutput("automerge", "true");
}
- name: Add automerge label
if: steps.analyze.outputs.automerge == 'true'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["automerge"]
})

0 comments on commit dfd43f7

Please sign in to comment.