fix(ci): fail fast when the deploy dir has no DATABASE_URL
Gitea Actions Runner Test / test-job (push) Successful in 1s
CI / check (push) Successful in 34s
CI / tests-unit (push) Successful in 1m42s
CI / tests-integration (push) Successful in 1m48s
CI / tests-ui (push) Successful in 2m35s
CI / preflight (push) Skipped
CI / deploy (push) Failing after 1m37s
Gitea Actions Runner Test / test-job (push) Successful in 1s
CI / check (push) Successful in 34s
CI / tests-unit (push) Successful in 1m42s
CI / tests-integration (push) Successful in 1m48s
CI / tests-ui (push) Successful in 2m35s
CI / preflight (push) Skipped
CI / deploy (push) Failing after 1m37s
pnpm db:migrate runs on the host and reads DATABASE_URL from the deploy directory's .env. When that variable was missing the deploy had already built an image and run the browser gate before pnpm db:migrate aborted on an empty value, so a release was paid for in full and then thrown away. Check for the variable right after the .env is copied, before the build, and say plainly that the live release was not touched. The deploy test fixture gains a DATABASE_URL so it mirrors a working deploy directory instead of the broken one.
This commit is contained in:
1 parent
bc00ecf08c
commit
80d7ae14ba
2 files changed
+18
-1
No files matched your search
@@ -92,6 +92,18 @@ for managed_name in epicnext-cms epicnext-cms-app; do
|
|||||||
docker inspect --format '{{.Name}} running={{.State.Running}} pid={{.State.Pid}} image={{.Image}}' "$managed_name" 2>/dev/null || true
|
docker inspect --format '{{.Name}} running={{.State.Running}} pid={{.State.Pid}} image={{.Image}}' "$managed_name" 2>/dev/null || true
|
||||||
done
|
done
|
||||||
[ "$deploy_dir/.env" -ef .env ] || cp "$deploy_dir/.env" .env
|
[ "$deploy_dir/.env" -ef .env ] || cp "$deploy_dir/.env" .env
|
||||||
|
|
||||||
|
# De migraties draaien op de host tegen DATABASE_URL, niet in de container. Die
|
||||||
|
# waarde staat alleen in $deploy_dir/.env, dus controleer hem hier: anders
|
||||||
|
# bouwen we eerst een image en doorlopen we de browsergate voordat `db:migrate`
|
||||||
|
# op een lege DATABASE_URL stukloopt. Dat is een halve release voor niets.
|
||||||
|
if ! grep -qs '^DATABASE_URL=' .env; then
|
||||||
|
echo "Error: DATABASE_URL ontbreekt in $deploy_dir/.env" >&2
|
||||||
|
echo " Zet daar een DATABASE_URL (mysql://user:pass@host:3306/db) en draai opnieuw." >&2
|
||||||
|
echo " De live release is niet aangeraakt; deze release is niet uitgerold." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
pnpm install --frozen-lockfile
|
pnpm install --frozen-lockfile
|
||||||
pnpm exec playwright install chromium
|
pnpm exec playwright install chromium
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,12 @@ function simulate(
|
|||||||
const dir = mkdtempSync(join(tmpdir(), "cms-deploy-test-"));
|
const dir = mkdtempSync(join(tmpdir(), "cms-deploy-test-"));
|
||||||
try {
|
try {
|
||||||
mkdirSync(join(dir, "production"));
|
mkdirSync(join(dir, "production"));
|
||||||
writeFileSync(join(dir, "production", ".env"), 'HOTEL_NAME="Test Hotel"\n');
|
// Een werkende deploymap heeft een DATABASE_URL; die gebruikt
|
||||||
|
// scripts/ci-deploy.sh voor de migraties op de host.
|
||||||
|
writeFileSync(
|
||||||
|
join(dir, "production", ".env"),
|
||||||
|
'HOTEL_NAME="Test Hotel"\nDATABASE_URL="mysql://test:[email protected]:3306/test"\n',
|
||||||
|
);
|
||||||
if (previous) writeFileSync(join(dir, previous), "old\n");
|
if (previous) writeFileSync(join(dir, previous), "old\n");
|
||||||
if (both) writeFileSync(join(dir, "epicnext-cms-app"), "old\n");
|
if (both) writeFileSync(join(dir, "epicnext-cms-app"), "old\n");
|
||||||
const result = spawnSync(bash, [resolve(root, "scripts/ci-deploy.sh")], {
|
const result = spawnSync(bash, [resolve(root, "scripts/ci-deploy.sh")], {
|
||||||
|
|||||||
Reference in new issue
Block a user