ci(build): build pull requests merged into current main

This commit is contained in:
Dean Galvin
2026-10-09 23:00:01 +13:00
parent 43972e69a1
commit 5994806a8b
2 changed files with 11 additions and 4 deletions
+10 -3
View File
@@ -72,13 +72,20 @@ jobs:
if (!Number.isSafeInteger(pull_number) || pull_number < 1) {
throw new Error('Invalid pull request number');
}
const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number });
let { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number });
for (let attempt = 0; pr.mergeable === null && attempt < 10; ++attempt) {
await new Promise((resolve) => setTimeout(resolve, 3000));
({ data: pr } = await github.rest.pulls.get({ owner, repo, pull_number }));
}
if (pr.state !== 'open' || pr.base.ref !== 'main') {
throw new Error('The pull request must be open and target main');
}
if (!manual && pr.head.sha !== context.payload.pull_request.head.sha) {
throw new Error('The pull request has newer commits; use the latest run');
}
if (pr.mergeable !== true || !pr.merge_commit_sha) {
throw new Error('The pull request does not merge cleanly into main; rebase it first');
}
let relinker = manual;
if (!manual) {
const { data: commits } = await github.rest.repos.listCommits({
@@ -86,11 +93,11 @@ jobs:
});
relinker = commits.length > 0;
}
core.setOutput('sha', pr.head.sha);
core.setOutput('sha', pr.merge_commit_sha);
core.setOutput('relinker', relinker);
core.setOutput('full', manual);
await core.summary.addRaw(
`PR #${pull_number} at ${pr.head.sha}: full builds ${manual ? 'enabled' : 'disabled'}, ` +
`PR #${pull_number} at ${pr.head.sha} merged into main as ${pr.merge_commit_sha}: full builds ${manual ? 'enabled' : 'disabled'}, ` +
`relinker ${relinker ? 'enabled' : 'skipped because the author has no commit in main'}`
).write();