Bootstrap protected release branches through the API - #32
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the reusable release workflow to bootstrap protected release/v* branches via the GitHub Refs API before pushing the generated version/changelog commit, avoiding GitHub Actions’ restrictions when a brand-new branch history first introduces workflow files.
Changes:
- Record the protected base commit SHA early in the
releasejob for later branch creation. - Create
refs/heads/release/v{VERSION}viagh apibefore pushing the release-preparation commit. - Keep the existing release-preparation PR creation/auto-merge flow, but make branch creation compatible with protected bases.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+652
to
+656
| if ! git ls-remote --exit-code --heads origin "$BRANCH" >/dev/null 2>&1; then | ||
| gh api --method POST "repos/${{ github.repository }}/git/refs" \ | ||
| -f "ref=refs/heads/$BRANCH" \ | ||
| -f "sha=${{ steps.release_base.outputs.sha }}" | ||
| fi |
Comment on lines
658
to
660
| git switch -c "$BRANCH" | ||
| git push --force-with-lease origin "HEAD:$BRANCH" | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Creates a release branch at the current protected base through the GitHub refs API before pushing the generated version/changelog commit.
Why
The first protected-release run could not push a new branch because its history contained a workflow-file change. GitHub Actions rejected that push without a workflow permission, even though the generated release commit does not edit workflows.
Impact
The release preparation PR can now be created without bypassing branch protection or granting a workflow token broader workflow-edit authority.
Validation