diff --git a/dist/index.js b/dist/index.js index e1a6acd0ac..e515fbf6b7 100644 --- a/dist/index.js +++ b/dist/index.js @@ -315,6 +315,12 @@ function createPullRequest(inputs) { if (branchRemoteName == 'origin' && base == inputs.branch) { throw new Error(`The 'base' and 'branch' for a pull request must be different branches. Unable to continue.`); } + // For self-hosted runners the repository state persists between runs. + // This command prunes the stale remote ref when the pull request branch was + // 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]); core.endGroup(); // Apply the branch suffix if set if (inputs.branchSuffix) { diff --git a/src/create-pull-request.ts b/src/create-pull-request.ts index ae99875ab1..5691b0591c 100644 --- a/src/create-pull-request.ts +++ b/src/create-pull-request.ts @@ -106,6 +106,12 @@ export async function createPullRequest(inputs: Inputs): Promise { `The 'base' and 'branch' for a pull request must be different branches. Unable to continue.` ) } + // For self-hosted runners the repository state persists between runs. + // This command prunes the stale remote ref when the pull request branch was + // 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]) core.endGroup() // Apply the branch suffix if set