From 0edcc985fadcce64f01fb77b1c15653d5e66e864 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Wed, 11 Jun 2025 11:51:22 -0700 Subject: [PATCH] use pr head ref --- script/patch-up.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/script/patch-up.js b/script/patch-up.js index 760972389e..0b6d91a824 100644 --- a/script/patch-up.js +++ b/script/patch-up.js @@ -41,7 +41,7 @@ function getCurrentCommitSha () { } function getCurrentBranch () { - return process.env.GITHUB_REF; + return process.env.GITHUB_HEAD_REF; } async function main () { @@ -49,6 +49,12 @@ async function main () { throw new Error('PATCH_UP_APP_CREDS environment variable not set'); } + const currentBranch = getCurrentBranch(); + + if (!currentBranch) { + throw new Error('GITHUB_HEAD_REF environment variable not set. Patch Up only works in PR workflows currently.'); + } + const octokit = new Octokit({ ...await getAuthOptionsForRepo({ name: REPO_OWNER, @@ -60,7 +66,6 @@ async function main () { // Get current git state const currentCommitSha = getCurrentCommitSha(); - const currentBranch = getCurrentBranch(); // Get the tree SHA from the current commit const currentCommit = await octokit.git.getCommit({