Repository navigation
Fail the action when a backport fails, retry pushes, and report git errors - #21
Merged
Merged
Conversation
…rrors - Mark the action as failed when any backport branch fails, after posting the PR comment and labels, so the workflow run no longer shows as passed. - Retry git push up to 3 times, since GitHub sometimes rejects pushes transiently (for example when its workflow-file check times out). - Include git's stderr in the error, so the PR comment says why git failed instead of only the exit code. - Bump version to 2.0.13 so merging publishes a release. Amp-Thread-ID: https://ampcode.com/threads/T-5c922310-4117-4bfd-8e10-34ae4aaca078
DaedalusG
marked this pull request as ready for review
November 18, 2026 04:48
DaedalusG
enabled auto-merge (squash)
November 18, 2026 06:00
michaellzc
approved these changes
Nov 18, 2026
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.
Problem
When a backport to a release branch fails, the action posts a failure comment and labels on the PR, but the job still succeeds. The error for each branch is caught in
backport()and never reachessetFailed. In the last 200 Backport runs in sourcegraph/sourcegraph, none failed, even though at least 15 PRs gotfailed-backport-to-*labels in that time.Example: run 44198843437 for sourcegraph/sourcegraph#19164 passed. Its push had been rejected with
Unable to determine if workflow can be created or updated due to timeout; workflows scope may be required., and the PR comment only saidThe process '/usr/bin/git' failed with exit code 1.Changes
backport()now returns the branches that failed. After settingcreated_pull_requests,index.tscallssetFailedif any branch failed. The failure comment and labels are still posted first, so a failure on one branch doesn't stop the others.git push. The push is tried up to 3 times, waiting 10 seconds and then 20 seconds, with a warning each time. This covers rejections that pass on a second try. It does not fix the 8.2.x timeouts above: those fail every time, and the fix for them is adding theworkflowscope to the token.githelper captures stderr and puts it in the error. The PR comment now shows, for example, the! [remote rejected] ... (reason)line orerror: could not apply ...instead of only the exit code..github/workflows/backport.ymlupdated.Test plan
yarn buildandyarn xopass. I ran the builtdist/index.jsend to end with a local bare repo as the remote (a pre-receive hook rejects pushes) and a local HTTP server standing in for the GitHub API:remote rejectedoutputerror: could not apply ...In all failure cases the comment and the
release-blockerandfailed-backport-to-*labels are still posted.