Files
hmbown--codewhale/web/scripts/check-cloudflare-deploy-env.mjs
wehub-resource-sync d68f003000
CI / Change detection (push) Has been cancelled
CI / Version drift (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Workflow RLM cache (push) Has been cancelled
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / npm wrapper smoke (push) Has been cancelled
CI / Mobile runtime smoke (push) Has been cancelled
CI / Workflow lint (push) Has been cancelled
CI / Documentation (push) Has been cancelled
Web Frontend / Lint & Type Check (push) Failing after 1s
Auto-close harvested PRs / close (push) Failing after 1s
cargo-deny / cargo-deny (bans licenses sources) (push) Failing after 1s
Security audit / cargo-audit (push) Failing after 1s
Sync to CNB / sync (push) Failing after 1s
cargo-deny / cargo-deny (advisories) (push) Failing after 3s
Web Frontend / Deploy to Cloudflare (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:08:23 +08:00

69 lines
2.0 KiB
JavaScript

#!/usr/bin/env node
/**
* check-cloudflare-deploy-env.mjs - fail fast when the GitHub deploy job is
* missing Cloudflare credentials.
*
* The actual deploy still belongs to Wrangler/OpenNext. This script only makes
* the common GitHub Actions failure mode obvious before the expensive build
* starts.
*/
const required = [
{
name: "CLOUDFLARE_ACCOUNT_ID",
source: "repository variable",
expected: "Settings > Secrets and variables > Actions > Variables",
validate(value) {
return /^[a-f0-9]{32}$/i.test(value);
},
detail: "expected the 32-character Cloudflare account id",
},
{
name: "CLOUDFLARE_API_TOKEN",
source: "repository secret",
expected: "Settings > Secrets and variables > Actions > Secrets",
validate(value) {
return value.length >= 20;
},
detail: "expected a non-empty Cloudflare API token",
},
];
const placeholderPattern = /^(changeme|replace(_with)?|todo|example|dummy|null|undefined)$/i;
const failures = [];
for (const item of required) {
const value = (process.env[item.name] ?? "").trim();
if (!value || placeholderPattern.test(value)) {
failures.push({
item,
reason: `${item.name} is not set`,
});
continue;
}
if (!item.validate(value)) {
failures.push({
item,
reason: `${item.name} is set but does not look valid`,
});
}
}
if (failures.length > 0) {
console.error("[check-cloudflare-deploy-env] FAIL - Cloudflare deploy configuration is incomplete.");
for (const failure of failures) {
const { item, reason } = failure;
console.error("");
console.error(`- ${reason}`);
console.error(` Configure ${item.name} as a GitHub ${item.source}.`);
console.error(` Location: ${item.expected}.`);
console.error(` Hint: ${item.detail}.`);
}
console.error("");
console.error("Wrangler deploy was not started.");
process.exit(1);
}
console.log("[check-cloudflare-deploy-env] OK - Cloudflare deploy environment is present.");