feat(ci): deploy-infra pipeline + env-driven site identity (spec-v4-deploy-infra rev.6-7)

Repo side of spec-v4-deploy-infra: deploy-infra.yml (paths-filtered nginx redeploy, test-before-touch, health probe); compose.yaml rename + secrets/site_config entrypoint override; site identity externalized - SITE_URL/SITE_NAME read from env (site.ts, vite site-identity plugin, index.html tokens, generated robots.txt); nginx.conf/vite dev proxy read GITEA_CONTENTS_API; .env.example; AGENTS.md + specs updated. Rev.7: site identity delivered as Gitea Actions variables (vars. context, public values) instead of secrets; upload-artifact unified to v7 across jobs.
This commit is contained in:
dong.nguyen committed 2026-10-23 22:34:23 +07:00
1 parent a1c249c504
commit 5e9c76c62b
16 files changed
+477 -91

No files matched your search

+13 -4
View File
@@ -14,13 +14,15 @@ if (!existsSync(distDir)) {
process.exit(1);
}
// index.html carries the canonical origin as static markup; site.ts carries it as data.
// A mismatch means one of the two was edited without the other.
// The published head is generated from %SITE_URL% tokens (site-identity vite
// plugin, spec-v4-deploy-infra D10); this guard validates that the injection
// actually happened with the same value this script derives its URLs from — a
// mismatch means the build ran without a consistent SITE_URL.
const indexHtml = readFileSync(join(distDir, 'index.html'), 'utf-8');
if (!indexHtml.includes(siteUrl)) {
console.error(
`Canonical origin mismatch: index.html does not contain "${siteUrl}". ` +
`Update the canonical/og:url/theme-color block in index.html or src/data/site.ts.`
`Canonical origin mismatch: dist/index.html does not contain "${siteUrl}". ` +
`The site-identity plugin injects it from SITE_URL — check the build environment.`,
);
process.exit(1);
}
@@ -42,3 +44,10 @@ const xml = `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.s
writeFileSync(join(distDir, 'sitemap.xml'), xml);
console.log(`sitemap.xml generated at ${join(distDir, 'sitemap.xml')} (${locations.length} urls)`);
// robots.txt is generated here too (spec-v4-deploy-infra D10): the Sitemap:
// pointer must derive from the same siteUrl as the sitemap itself, so there is
// no committed robots.txt that could drift from it.
const robots = `User-agent: *\nAllow: /\n\nSitemap: ${siteUrl}/sitemap.xml\n`;
writeFileSync(join(distDir, 'robots.txt'), robots);
console.log(`robots.txt generated at ${join(distDir, 'robots.txt')}`);