fuzzyworld

word-waltz / commit

ci pasta

82674e8a0ba840817d4f575106b02b9b5ea39d66 · Pavel Safronov · 2026-03-23 16:56:27 -0700 · parents a0df624b260c

ci pasta
 .gitlab-ci.yml               | 16 +++++-----------
 README.md                    |  4 ++--
 scripts/cleanup-old-games.js | 14 ++++++++++++--
 vite.config.ts               |  3 +++
 4 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9a2b698..7612aa9 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -35,21 +35,15 @@ pages:
   needs:
     - build
 
-# Firebase config is injected as masked GitLab CI/CD variables:
-#   VITE_FIREBASE_API_KEY
-#   VITE_FIREBASE_AUTH_DOMAIN
-#   VITE_FIREBASE_PROJECT_ID
-#   VITE_FIREBASE_STORAGE_BUCKET
-#   VITE_FIREBASE_MESSAGING_SENDER_ID
-#   VITE_FIREBASE_APP_ID
-# Vite bakes these into the static bundle at build time.
+# Firebase config is committed directly in src/firebase/config.ts.
+# No CI/CD variables are needed for the build job.
 
 # ---------------------------------------------------------------------------
 # Scheduled cleanup — deletes Firestore games inactive for > 30 days.
 # Trigger: create a Pipeline Schedule in GitLab (e.g. "0 3 * * *" = 03:00 UTC).
-# Required masked CI/CD variables:
-#   FIREBASE_SERVICE_ACCOUNT_JSON  — service-account JSON with Firestore access
-#   VITE_FIREBASE_PROJECT_ID       — already used by the build job above
+# Required masked CI/CD variable for the cleanup job:
+#   FIREBASE_SERVICE_ACCOUNT_JSON  — service-account JSON with Firestore write access
+# The Firebase project ID is read from src/firebase/config.ts in the repo.
 # ---------------------------------------------------------------------------
 cleanup-old-games:
   stage: cleanup
diff --git a/README.md b/README.md
index 8bb6eaa..ccaec8f 100644
--- a/README.md
+++ b/README.md
@@ -112,5 +112,5 @@ npm run build      # Outputs to dist/
 
 1. Create a Firebase project at [console.firebase.google.com](https://console.firebase.google.com).
 2. Enable **Firestore** in Native mode.
-3. Set Firestore security rules so that **any authenticated or unauthenticated client can read/write documents** — the encryption layer handles confidentiality, so open Firestore rules are acceptable. Alternatively, restrict by document ID format.
-4. Paste your Firebase project config into `src/firebase/config.js`.
+3. Set Firestore security rules (see guidance in `AGENTS.md`).
+4. The Firebase project config is committed directly in `src/firebase/config.ts`.
diff --git a/scripts/cleanup-old-games.js b/scripts/cleanup-old-games.js
index 5dfe179..57e2999 100644
--- a/scripts/cleanup-old-games.js
+++ b/scripts/cleanup-old-games.js
@@ -10,11 +10,13 @@
  *
  * Required environment variables:
  *   FIREBASE_SERVICE_ACCOUNT_JSON  — full service-account JSON (masked CI/CD variable)
- *   VITE_FIREBASE_PROJECT_ID       — Firebase project ID (already used by the build)
+ *
+ * The Firebase project ID is read directly from src/firebase/config.ts in the repo.
  *
  * Schedule via a GitLab pipeline schedule (e.g. daily at 03:00 UTC).
  */
 
+import { readFileSync } from 'fs';
 import { initializeApp, cert } from 'firebase-admin/app';
 import { getFirestore } from 'firebase-admin/firestore';
 
@@ -30,8 +32,16 @@ function requireEnv(name) {
     return value;
 }
 
+// Extract projectId from the committed Firebase config (avoids a separate CI variable).
+const configSource = readFileSync(new URL('../src/firebase/config.ts', import.meta.url), 'utf8');
+const projectIdMatch = configSource.match(/projectId:\s*["']([^"']+)["']/);
+if (!projectIdMatch) {
+    console.error('Error: could not extract projectId from src/firebase/config.ts');
+    process.exit(1);
+}
+const projectId = projectIdMatch[1];
+
 const serviceAccount = JSON.parse(requireEnv('FIREBASE_SERVICE_ACCOUNT_JSON'));
-const projectId = requireEnv('VITE_FIREBASE_PROJECT_ID');
 
 initializeApp({ credential: cert(serviceAccount), projectId });
 const db = getFirestore();
diff --git a/vite.config.ts b/vite.config.ts
index 1fb7072..db2e9bf 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -3,6 +3,9 @@ import { defineConfig } from 'vite';
 export default defineConfig({
   // src/index.html is the entry point; Vite resolves assets relative to it
   root: 'src',
+  // GitLab project Pages are served at /<project-name>/.
+  // Use '/' locally (dev server) and the project sub-path in CI.
+  base: process.env.CI ? '/word-waltz/' : '/',
   build: {
     outDir: '../dist',
     emptyOutDir: true,