fuzzyworld

north-star / commit

ci pasta

5be7df9b57111fc9f0c2d86ba81d237055442c9d · Pavel Safronov · 2026-03-15 17:33:05 -0700 · parents 1058214299f1

ci pasta
 .gitlab-ci.yml | 2 +-
 package.json   | 3 ++-
 src/app.js     | 3 +--
 src/commit.js  | 2 ++
 4 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index be777fb..6c2a677 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -13,5 +13,5 @@ create-pages:
   script:
     - echo "Building North Star from commit ${CI_COMMIT_SHORT_SHA}..."
     - mkdir -p public
-    - echo "export const GIT_COMMIT='${CI_COMMIT_SHORT_SHA}';" > public/commit.js
+    - npm run gen-commit-js
     - npm run build
diff --git a/package.json b/package.json
index 2e46e54..6cabb8c 100644
--- a/package.json
+++ b/package.json
@@ -6,7 +6,8 @@
     "scripts": {
         "dev": "vite",
         "build": "vite build",
-        "preview": "vite preview"
+        "preview": "vite preview",
+        "gen-commit-js": "echo \"export const GIT_COMMIT='${CI_COMMIT_SHORT_SHA}';\" > public/commit.js"
     },
     "dependencies": {
         "firebase": "^12.0.0",
diff --git a/src/app.js b/src/app.js
index 7b7ca34..bff1b5e 100644
--- a/src/app.js
+++ b/src/app.js
@@ -51,8 +51,7 @@ initDarkMode(darkModeToggle);
 const { requestWakeLock } = createWakeLockManager();
 
 try {
-    const commitUrl = `${import.meta.env.BASE_URL}commit.js`;
-    const commitModule = await import(/* @vite-ignore */ commitUrl);
+    const commitModule = await import('./commit.js');
     if (typeof commitModule.GIT_COMMIT === 'string') {
         GIT_COMMIT = commitModule.GIT_COMMIT;
         isLocalCommit = false;
diff --git a/src/commit.js b/src/commit.js
new file mode 100644
index 0000000..a69cf65
--- /dev/null
+++ b/src/commit.js
@@ -0,0 +1,2 @@
+// This file is meant to be generated during the build process, but we need it to exist in the source directory for development purposes. The build process will replace the value of GIT_COMMIT with the actual commit hash or version string.
+export const GIT_COMMIT = 'local';
\ No newline at end of file