Skip to content

Commit

Permalink
Automerge release pull requests (#4595)
Browse files Browse the repository at this point in the history
  • Loading branch information
sashuk authored Oct 8, 2024
1 parent 4379597 commit 774abf2
Showing 1 changed file with 11 additions and 26 deletions.
37 changes: 11 additions & 26 deletions .github/workflows/automerge-release.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Automatically merge non-major release PR
name: Automatically merge release PR

on:
pull_request:
Expand All @@ -7,9 +7,6 @@ on:
types:
- opened

env:
PR_NUMBER: ${{ github.event.number }}
PR_BODY: ${{ github.event.pull_request.body }}
jobs:
merge-release-pr:
if: ${{ github.event.pull_request.head.ref == 'changeset-release/master' }}
Expand Down Expand Up @@ -39,35 +36,23 @@ jobs:
with:
json: ${{ steps.secrets_manager.outputs.secrets }}

- name: Set ENV Variables
run: |-
echo "DEVBOT_TOKEN=${{ steps.parse_secrets.outputs.TOPTAL_DEVBOT_TOKEN }}" >> $GITHUB_ENV
- name: Merge pull request if the release is not major
- name: Merge pull request
uses: actions/github-script@v7
with:
github-token: ${{ env.DEVBOT_TOKEN }}
github-token: ${{ steps.parse_secrets.outputs.TOPTAL_DEVBOT_TOKEN }}
script: |
const { PR_NUMBER, PR_BODY } = process.env
const repository = context.repo
const isMajorRelease = PR_BODY.includes("### Major Changes")
const commentBody = isMajorRelease ?
"This pull request seems to be a **major** release and will **not** be merged automatically"
: "This pull request seems to be a **non-major** release and will be merged automatically"
const commentBody = "This release pull request will be merged automatically"
await github.rest.issues.createComment({
owner: repository.owner,
issue_number: PR_NUMBER,
issue_number: ${{ github.event.number }},
repo: repository.repo,
body: commentBody,
})
if (!isMajorRelease) {
await github.rest.pulls.merge({
merge_method: "squash",
owner: repository.owner,
pull_number: PR_NUMBER,
repo: repository.repo,
})
}
await github.rest.pulls.merge({
merge_method: "squash",
owner: repository.owner,
pull_number: ${{ github.event.number }},
repo: repository.repo,
})

0 comments on commit 774abf2

Please sign in to comment.