From 2b489e83bafdd5cf1f7655537f677e6ea0fab853 Mon Sep 17 00:00:00 2001 From: Arif Hasanic Date: Sun, 31 Aug 2025 16:58:19 +0200 Subject: [PATCH 1/7] write git sha env variable into docker container --- .github/workflows/ci.yml | 4 ++-- nginx.conf | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 31fd769..9c69dd1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,8 +18,8 @@ jobs: run: bun install - name: Build run: bun run build - - name: Write git hash into dist - run: echo "export const GIT_HASH = '$(git rev-parse HEAD)';" > dist/git-hash.js + - name: Write GITHUB_SHA into dist + run: echo "export const GITHUB_SHA = '$GITHUB_SHA';" > dist/git-hash.js - name: Create Build Artifact uses: christopherhx/gitea-upload-artifact@v4 with: diff --git a/nginx.conf b/nginx.conf index a7fecc1..7e9c8a0 100644 --- a/nginx.conf +++ b/nginx.conf @@ -16,7 +16,7 @@ http { index index.html; location / { - try_files $uri $uri/ /index.html; + try_files $uri $uri/ /index.html /git-hash.js; } location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { -- 2.49.1 From 83f872577ba7faf044604d2cca4314728526482e Mon Sep 17 00:00:00 2001 From: Arif Hasanic Date: Sun, 31 Aug 2025 17:01:10 +0200 Subject: [PATCH 2/7] ensure git-hash.js is in dist folder --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c69dd1..a1352bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,9 +17,9 @@ jobs: - name: Install dependencies run: bun install - name: Build - run: bun run build - - name: Write GITHUB_SHA into dist - run: echo "export const GITHUB_SHA = '$GITHUB_SHA';" > dist/git-hash.js + run: | + bun run build + echo "export const GITHUB_SHA = '$GITHUB_SHA';" > dist/git-hash.js - name: Create Build Artifact uses: christopherhx/gitea-upload-artifact@v4 with: -- 2.49.1 From b6c9c51ec3ed7f7948ff7ca8c8771300d54bac3a Mon Sep 17 00:00:00 2001 From: Arif Hasanic Date: Sun, 31 Aug 2025 17:05:20 +0200 Subject: [PATCH 3/7] docker image now uses dist folder from build step for deploy --- Dockerfile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2185613..7837ff8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,5 @@ -FROM oven/bun as builder -WORKDIR /app -COPY . . -RUN bun install -RUN bun run build - FROM nginx:alpine -COPY --from=builder /app/dist /usr/share/nginx/html +COPY ./dist /usr/share/nginx/html COPY nginx.conf /etc/nginx/nginx.conf EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file -- 2.49.1 From 9872b64fbdeba0792494122baa71660ab4671e8a Mon Sep 17 00:00:00 2001 From: Arif Hasanic Date: Sun, 31 Aug 2025 17:10:57 +0200 Subject: [PATCH 4/7] create git hash html --- .github/workflows/ci.yml | 6 +++--- pipeline/build-image.sh | 1 - pipeline/create-git-hash-html.sh | 13 +++++++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) delete mode 100755 pipeline/build-image.sh create mode 100644 pipeline/create-git-hash-html.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a1352bc..2991939 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,9 +17,9 @@ jobs: - name: Install dependencies run: bun install - name: Build - run: | - bun run build - echo "export const GITHUB_SHA = '$GITHUB_SHA';" > dist/git-hash.js + run: bun run build + - name: Write Git-Hash into html + run: ./pipeline/create-git-hash-html.sh - name: Create Build Artifact uses: christopherhx/gitea-upload-artifact@v4 with: diff --git a/pipeline/build-image.sh b/pipeline/build-image.sh deleted file mode 100755 index cc1f786..0000000 --- a/pipeline/build-image.sh +++ /dev/null @@ -1 +0,0 @@ -#!/bin/bash \ No newline at end of file diff --git a/pipeline/create-git-hash-html.sh b/pipeline/create-git-hash-html.sh new file mode 100644 index 0000000..7af279f --- /dev/null +++ b/pipeline/create-git-hash-html.sh @@ -0,0 +1,13 @@ +#!/bin/sh + + +# create git-hash.html +echo " + + + Git Hash + + +
GITHUB_SHA = '$GITHUB_SHA';
+ +" > dist/git-hash.html \ No newline at end of file -- 2.49.1 From 756e7091810c0252b13e2547a4b46519fc820510 Mon Sep 17 00:00:00 2001 From: Arif Hasanic Date: Sun, 31 Aug 2025 17:11:21 +0200 Subject: [PATCH 5/7] correct permission on shell script --- pipeline/create-git-hash-html.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 pipeline/create-git-hash-html.sh diff --git a/pipeline/create-git-hash-html.sh b/pipeline/create-git-hash-html.sh old mode 100644 new mode 100755 -- 2.49.1 From 2b21310dfbb220e2dd2aadada2b96b994ce14cc7 Mon Sep 17 00:00:00 2001 From: Arif Hasanic Date: Sun, 31 Aug 2025 18:14:50 +0200 Subject: [PATCH 6/7] add githooks and setup.sh --- .github/workflows/ci.yml | 3 --- githooks/pre-commit | 12 ++++++++++++ pipeline/create-git-hash-html.sh | 2 -- setup.sh | 3 +++ 4 files changed, 15 insertions(+), 5 deletions(-) create mode 100755 githooks/pre-commit create mode 100755 setup.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2991939..284c28f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,7 +60,6 @@ jobs: run: docker build -t git.rivercry.com/wg/monitor-im-flur . - name: Push Docker image run: docker push git.rivercry.com/wg/monitor-im-flur - - name: Deploy via SSH uses: appleboy/ssh-action@v0.1.10 with: @@ -70,8 +69,6 @@ jobs: password: ${{ secrets.GARRISON_DOCKER_PASSWORD }} script: | cd monitor-im-flur - echo "Deploying Docker container..." - $HYPRLAND_INSTANCE_SIGNATURE hyprctl dispatch exec 'pkill firefox' hyprctl dispatch exec 'firefox -kiosk localhost:9123' git clean -dfx diff --git a/githooks/pre-commit b/githooks/pre-commit new file mode 100755 index 0000000..3849097 --- /dev/null +++ b/githooks/pre-commit @@ -0,0 +1,12 @@ +#!/bin/sh + +echo "Running pre-commit hooks..." + +biome check --write +biome lint --write + +if git diff --quiet; then + exit 0 +else + git add -u +fi diff --git a/pipeline/create-git-hash-html.sh b/pipeline/create-git-hash-html.sh index 7af279f..3eb1d94 100755 --- a/pipeline/create-git-hash-html.sh +++ b/pipeline/create-git-hash-html.sh @@ -1,7 +1,5 @@ #!/bin/sh - -# create git-hash.html echo " diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..0ba2c34 --- /dev/null +++ b/setup.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +git config --local core.hooksPath githooks -- 2.49.1 From 2c805ab513e91d8d2b414cadb18aa8e9e487cca4 Mon Sep 17 00:00:00 2001 From: Arif Hasanic Date: Sun, 31 Aug 2025 18:21:05 +0200 Subject: [PATCH 7/7] dont publish if lint fails --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 284c28f..a133eff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,7 +42,7 @@ jobs: run: biome ci . create-and-publish-docker-image: - needs: [build] + needs: [lint] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 -- 2.49.1