Skip to content

Commit 891c532

Browse files
authored
feat(workflow-release): auto merge PR after creating (#18)
2 parents 7f9f953 + 85a272f commit 891c532

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

.github/workflows/release.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,24 @@ jobs:
5959
--title "${{ env.RELEASE_TAG }}" \
6060
--generate-notes
6161
62-
- name: Create merge PR ${{ github.head_ref }} -> ${{ env.BRANCH_DEVELOP }}
62+
- name: Create PR ${{ github.head_ref }} -> ${{ env.BRANCH_DEVELOP }} and merge automatically
6363
env:
6464
PR_TITLE: Merge branch '${{ github.head_ref }}' into ${{ env.BRANCH_DEVELOP }}
6565
PR_BODY: |
66-
This PR merges the ${{ github.head_ref }} branch back into ${{ env.BRANCH_DEVELOP }} branch.
67-
This happens to ensure that the updates that happened on the ${{ github.head_ref }} branch, i.e. CHANGELOG and manifest updates are also present on the ${{ env.BRANCH_DEVELOP }} branch.
66+
This PR merges the branch `${{ github.head_ref }}` back into the branch `${{ env.BRANCH_DEVELOP }}`.
67+
68+
This ensures that the updates on the branch `${{ github.head_ref }}`, i.e. CHANGELOG and manifest updates, are also present on the branch `${{ env.BRANCH_DEVELOP }}`.
6869
PR_LABEL: automated-pr
6970
run: |
7071
gh label create ${{ env.PR_LABEL }} --force
72+
7173
gh pr create \
7274
--base ${{ env.BRANCH_DEVELOP }} \
7375
--head ${{ github.head_ref }} \
7476
--title "${{ env.PR_TITLE }}" \
7577
--body "${{ env.PR_BODY }}" \
7678
--label "${{ env.PR_LABEL }}" \
7779
--fill
80+
81+
PR_ID=$(gh pr list --state open --search "base:${{ env.BRANCH_DEVELOP }} head:${{ github.head_ref }}" | head -1 | cut -f1)
82+
[[ ! -z "$PR_ID" ]] && gh pr merge ${PR_ID} -d -t "${{ env.PR_TITLE }}" || echo "Empty PR ID. Ignored!"

0 commit comments

Comments
 (0)