use pr head ref

This commit is contained in:
Samuel Attard
2025-06-11 11:51:22 -07:00
parent 37402a18a4
commit 0edcc985fa

View File

@@ -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({