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 authored and GitHub committed 2026-01-21 15:04:51 +00:00
1 parent 34aa40e9cf
commit 70001242bf
3 files changed
+23 -2

No files matched your search

+7 -1
View File
@@ -127,7 +127,13 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
// 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
await git.exec(['remote', 'prune', branchRemoteName])
try {
await git.exec(['remote', 'prune', branchRemoteName])
} catch (error) {
core.warning(
`Failed to prune remote '${branchRemoteName}': ${(error as Error).message}`
)
}
}
core.endGroup()