Files
marqdo-site/scripts/check-branch.mjs

10 lines
576 B
JavaScript

const url = 'https://git.cflmy.cn/api/v1/repos/cflmy/marqdo-site/branches/main';
const response = await fetch(url, { redirect: 'error', signal: AbortSignal.timeout(12_000) });
if (!response.ok) throw new Error(`Cannot verify protected main: HTTP ${response.status}`);
const branch = await response.json();
const sha = process.env.CI_COMMIT_SHA;
if (!/^[0-9a-f]{40}$/.test(sha ?? '') || branch.protected !== true || sha !== branch.commit?.id) {
throw new Error('Release candidates require the current protected main commit');
}
console.log(`Protected website main: ${sha}`);