diff --git a/dist/index.js b/dist/index.js index 28a67b4..6bfac2d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -5749,14 +5749,15 @@ function createBranch(getOctokit, context, branch, sha) { const toolkit = getOctokit(githubToken()); // Sometimes branch might come in with refs/heads already branch = branch.replace('refs/heads/', ''); + const ref = `refs/heads/${branch}`; // throws HttpError if branch already exists. try { yield toolkit.rest.repos.getBranch(Object.assign(Object.assign({}, context.repo), { branch })); } catch (error) { if (error.name === 'HttpError' && error.status === 404) { - const resp = yield toolkit.rest.git.createRef(Object.assign({ ref: `refs/heads/${branch}`, sha: sha || context.sha }, context.repo)); - return ((_a = resp === null || resp === void 0 ? void 0 : resp.data) === null || _a === void 0 ? void 0 : _a.ref) === branch; + const resp = yield toolkit.rest.git.createRef(Object.assign({ ref, sha: sha || context.sha }, context.repo)); + return ((_a = resp === null || resp === void 0 ? void 0 : resp.data) === null || _a === void 0 ? void 0 : _a.ref) === ref; } else { throw Error(error); diff --git a/src/create-branch.ts b/src/create-branch.ts index 1fb42b9..cf65981 100644 --- a/src/create-branch.ts +++ b/src/create-branch.ts @@ -4,6 +4,7 @@ export async function createBranch(getOctokit: any, context: Context, branch: st const toolkit = getOctokit(githubToken()); // Sometimes branch might come in with refs/heads already branch = branch.replace('refs/heads/', ''); + const ref = `refs/heads/${branch}`; // throws HttpError if branch already exists. try { @@ -14,12 +15,12 @@ export async function createBranch(getOctokit: any, context: Context, branch: st } catch (error: any) { if (error.name === 'HttpError' && error.status === 404) { const resp = await toolkit.rest.git.createRef({ - ref: `refs/heads/${branch}`, + ref, sha: sha || context.sha, ...context.repo, }); - return resp?.data?.ref === branch; + return resp?.data?.ref === ref; } else { throw Error(error); }