fix: Handle remote prune failures gracefully (#4295)

Wrap the git remote prune command in a try-catch block to prevent
the action from failing if the prune operation fails. Instead, log
a warning message and allow the action to continue.

Fixes edge cases where the prune command may fail on self-hosted
runners but shouldn't block the pull request creation workflow.
This commit is contained in:
Peter Evans
2026-01-21 15:04:51 +00:00
committed by GitHub
parent 34aa40e9cf
commit 70001242bf
3 changed files with 23 additions and 2 deletions

7
dist/index.js vendored
View File

@@ -458,7 +458,12 @@ function createPullRequest(inputs) {
// deleted after being merged or closed. Without this the push using
// '--force-with-lease' fails due to "stale info."
// https://github.com/peter-evans/create-pull-request/issues/633
yield git.exec(['remote', 'prune', branchRemoteName]);
try {
yield git.exec(['remote', 'prune', branchRemoteName]);
}
catch (error) {
core.warning(`Failed to prune remote '${branchRemoteName}': ${error.message}`);
}
}
core.endGroup();
// Apply the branch suffix if set