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

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()