[ci] Force-update release branch on tagged main commits - #977
Conversation
Signed-off-by: Andrei Kvapil <[email protected]>
WalkthroughThe workflow for maintaining the Changes
Sequence Diagram(s)sequenceDiagram
participant Workflow
participant GitHubAPI
Workflow->>GitHubAPI: Get commit SHA for tag
alt Branch exists
Workflow->>GitHubAPI: Force-update branch to tag's commit SHA
else Branch does not exist
Workflow->>GitHubAPI: Create branch at tag's commit SHA
end
Workflow->>Workflow: Log actions
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. Note ⚡️ Faster reviews with cachingCodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 30th. To opt out, configure Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
.github/workflows/pull-requests-release.yaml (1)
110-117: Narrow the catch block to only missing-branch errors
The currenttry/catchtreats every error as “branch not found” and falls back tocreateRef. To avoid masking other API failures (rate limits, permissions, etc.), restrict the fallback to 404 responses:try { await github.rest.repos.getBranch({ owner, repo, branch }); // ...updateRef logic... } catch (err) { - // Branch doesn't exist, create it + if (err.status === 404) { await github.rest.git.createRef({ owner, repo, ref: `refs/heads/${branch}`, sha: commitSha }); console.log(`✅ Created branch '${branch}' at ${commitSha}`); + } else { + throw err; + } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/pull-requests-release.yaml(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Build and Test
🔇 Additional comments (2)
.github/workflows/pull-requests-release.yaml (2)
92-100: Ensure correct commit SHA for annotated tags
Currently, the workflow fetches the tag ref and usesref.data.object.shaas the commit SHA. This works for lightweight tags (which yourgit tag -fcreates), but for annotated tagsref.data.object.typewill be"tag"andref.data.object.shapoints to the tag object rather than the commit. To make this robust, consider checkingref.data.object.typeand, if it equals"tag", invokinggithub.rest.git.getTagon that tag SHA to dereference to the underlying commit SHA.
90-127: LGTM: maintenance branch now tracks the correct tag commit
The updated step explicitly fetches the tag’s commit SHA and either force-updates or creates therelease-X.Ybranch at that SHA, fixing the previous mismatch. The console logs are clear and the flow is well-structured.
Signed-off-by: Andrei Kvapil [email protected]
Summary by CodeRabbit