Skip to content

Commit bd05710

Browse files
committed
chore(push): Merge PR directly
1 parent b2897ac commit bd05710

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

.github/workflows/gem-push.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
permissions:
2020
contents: write # for commit, push, branch ops
2121
pull-requests: write # for creating/editing PR + adding labels
22+
packages: write
2223

2324
steps:
2425
- uses: actions/checkout@v6
@@ -95,12 +96,15 @@ jobs:
9596
- name: Push to release branch
9697
run: git push origin HEAD:refs/heads/${{ env.RELEASE_BRANCH }} --force
9798

98-
- name: Create or update PR with auto-merge label
99+
- name: Create PR and merge immediately
99100
env:
100101
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101102
run: |
102103
PR_TITLE="chore: update ${{ env.PACKAGE_NAME }} to ${{ env.VERSION }}"
103-
PR_BODY="Automated version bump to ${{ env.VERSION }} after release publication.\n\nOld version was ${{ env.OLD_VERSION }}."
104+
PR_BODY="Automated version bump to ${{ env.VERSION }} after release publication.\n\nOld version was ${{ env.OLD_VERSION }}.\n\nMerging immediately via workflow."
105+
106+
# Ensure label exists (optional, for visibility only now)
107+
gh label create "gem-release" --color "0E8A16" --description "Gem version bump PR" --force || true
104108
105109
# Check for existing open PR on this branch
106110
EXISTING_PR=$(gh pr list --head "${{ env.RELEASE_BRANCH }}" --state open --json number --jq '.[0].number // ""')
@@ -111,20 +115,30 @@ jobs:
111115
--title "$PR_TITLE" \
112116
--body "$PR_BODY"
113117
gh pr reopen "$EXISTING_PR" || true
118+
PR_NUMBER="$EXISTING_PR"
114119
else
115120
echo "Creating new PR"
116-
gh pr create \
121+
PR_URL=$(gh pr create \
117122
--base main \
118123
--head "${{ env.RELEASE_BRANCH }}" \
119124
--title "$PR_TITLE" \
120125
--body "$PR_BODY" \
121-
--label "auto-merge"
126+
--label "gem-release")
127+
PR_NUMBER=$(echo "$PR_URL" | grep -o '[0-9]\+')
122128
fi
123129
130+
# Immediately merge (squash is clean for version bumps; change to --merge or --rebase if preferred)
131+
echo "Merging PR #$PR_NUMBER immediately"
132+
gh pr merge "$PR_NUMBER" --squash --delete-branch || {
133+
echo "Immediate merge failed (likely due to checks/protection). Falling back to enable auto-merge."
134+
gh pr merge "$PR_NUMBER" --auto --squash --delete-branch || echo "Auto-merge enable also failed."
135+
}
136+
124137
- name: Trim old package versions
125138
if: env.IS_TEST_MODE != 'true'
126139
uses: actions/delete-package-versions@v5
127140
with:
128141
package-name: ${{ env.PACKAGE_NAME }}
129142
package-type: rubygems
130143
min-versions-to-keep: 5
144+
token: ${{ secrests.GEM_PUSH_TOKEN }}

0 commit comments

Comments
 (0)