Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
jakemhiller committed Jan 8, 2025
1 parent 69f108d commit 419980f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 45 deletions.
51 changes: 10 additions & 41 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64895,18 +64895,16 @@ let BASE_SHA;
encoding: 'utf-8',
});
const HEAD_SHA = headResult.stdout;
if ((['pull_request', 'pull_request_target'].includes(eventName) &&
!github.context.payload.pull_request.merged) ||
eventName == 'merge_group') {
try {
const mergeBaseRef = yield findMergeBaseRef();
const baseResult = (0, child_process_1.spawnSync)('git', ['merge-base', `origin/${mainBranchName}`, mergeBaseRef], { encoding: 'utf-8' });
BASE_SHA = baseResult.stdout;
}
catch (e) {
core.setFailed(e.message);
return;
}
if (['pull_request', 'pull_request_target'].includes(eventName) &&
!github.context.payload.pull_request.merged) {
const baseResult = (0, child_process_1.spawnSync)('git', ['merge-base', `origin/${mainBranchName}`, 'HEAD'], { encoding: 'utf-8' });
BASE_SHA = baseResult.stdout;
}
else if (eventName == 'merge_group') {
const baseResult = (0, child_process_1.spawnSync)('git', ['rev-parse', 'HEAD^1'], {
encoding: 'utf-8',
});
BASE_SHA = baseResult.stdout;
}
else {
try {
Expand Down Expand Up @@ -65016,35 +65014,6 @@ function findSuccessfulCommit(workflow_id, run_id, owner, repo, branch, lastSucc
return yield findExistingCommit(octokit, branch, shas);
});
}
function findMergeBaseRef() {
return __awaiter(this, void 0, void 0, function* () {
if (eventName == 'merge_group') {
const mergeQueueBranch = yield findMergeQueueBranch();
return `origin/${mergeQueueBranch}`;
}
else {
return 'HEAD';
}
});
}
function findMergeQueuePr() {
const { head_ref, base_sha } = github.context.payload.merge_group;
const result = new RegExp(`^refs/heads/gh-readonly-queue/${mainBranchName}/pr-(\\d+)-${base_sha}$`).exec(head_ref);
return result ? result.at(1) : undefined;
}
function findMergeQueueBranch() {
return __awaiter(this, void 0, void 0, function* () {
const pull_number = findMergeQueuePr();
if (!pull_number) {
throw new Error('Failed to determine PR number');
}
process.stdout.write('\n');
process.stdout.write(`Found PR #${pull_number} from merge queue branch\n`);
const octokit = new ProxifiedClient();
const result = yield octokit.request(`GET /repos/${owner}/${repo}/pulls/${pull_number}`, { owner, repo, pull_number: +pull_number });
return result.data.head.ref;
});
}
/**
* Get first existing commit
*/
Expand Down
17 changes: 13 additions & 4 deletions find-successful-workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,20 @@ let BASE_SHA: string;
});
const HEAD_SHA = headResult.stdout;

if (['pull_request', 'pull_request_target'].includes(eventName) && !github.context.payload.pull_request.merged) {
const baseResult = spawnSync('git', ['merge-base', `origin/${mainBranchName}`, 'HEAD'], { encoding: 'utf-8' });
if (
['pull_request', 'pull_request_target'].includes(eventName) &&
!github.context.payload.pull_request.merged
) {
const baseResult = spawnSync(
'git',
['merge-base', `origin/${mainBranchName}`, 'HEAD'],
{ encoding: 'utf-8' },
);
BASE_SHA = baseResult.stdout;
} else if (eventName == "merge_group") {
const baseResult = spawnSync('git', ['rev-parse', 'HEAD^1'], { encoding: 'utf-8' });
} else if (eventName == 'merge_group') {
const baseResult = spawnSync('git', ['rev-parse', 'HEAD^1'], {
encoding: 'utf-8',
});
BASE_SHA = baseResult.stdout;
} else {
try {
Expand Down

0 comments on commit 419980f

Please sign in to comment.