From 7ec0082fa6aebdf0cfe034c78e0ce5067f175c41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20Gr=C3=A6sberg?= Date: Tue, 15 Sep 2026 21:26:28 +0200 Subject: [PATCH 1/9] Update base url in project config --- "v\303\246r/vite.config.ts" | 1 + 1 file changed, 1 insertion(+) diff --git "a/v\303\246r/vite.config.ts" "b/v\303\246r/vite.config.ts" index 9982072..fc089ba 100644 --- "a/v\303\246r/vite.config.ts" +++ "b/v\303\246r/vite.config.ts" @@ -4,4 +4,5 @@ import { defineConfig } from 'vite' // https://vite.dev/config/ export default defineConfig({ plugins: [react()], + base: "/project1", }) From 90d48d813d35aa01c1509a267177b0bb71b7e98c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20Gr=C3=A6sberg?= Date: Tue, 15 Sep 2026 21:27:15 +0200 Subject: [PATCH 2/9] Remove unused hook --- "v\303\246r/src/hooks/useStorage.ts" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/v\303\246r/src/hooks/useStorage.ts" "b/v\303\246r/src/hooks/useStorage.ts" index 7ff75a1..589e460 100644 --- "a/v\303\246r/src/hooks/useStorage.ts" +++ "b/v\303\246r/src/hooks/useStorage.ts" @@ -1,4 +1,4 @@ -import { useState, useEffect, useCallback } from "react"; +import { useState, useCallback } from "react"; import { getData, saveData } from "../services/storage"; import type {AppStorage} from "../services/storage"; From ff340dc4526e6d7e3799146d05de0cdadeb3b779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20Gr=C3=A6sberg?= Date: Tue, 15 Sep 2026 22:32:26 +0200 Subject: [PATCH 3/9] Create action workflow for CI/CD deployment --- .github/workflows/deploy-to-vm.yaml | 45 +++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/deploy-to-vm.yaml diff --git a/.github/workflows/deploy-to-vm.yaml b/.github/workflows/deploy-to-vm.yaml new file mode 100644 index 0000000..39f0026 --- /dev/null +++ b/.github/workflows/deploy-to-vm.yaml @@ -0,0 +1,45 @@ +# Created with assistance from GPT-5.6 Terra High + +name: CI/CD - Deploy to VM +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: [self-hosted] + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: | + mkdir -p "$TEMPDIR" + npm ci --no-audit --no-fund + + - name: Build app + run: npm run Build + + - name: Deploy app to apache + run: | + set -euo pipefail + + test -d "/var/www/html/project1" + test -f dist/index.html + + rsync -a --delete --chmod=D755,F644 \ + dist/ "/var/www/html/project1/" + + - name: Cleanup job files + if: always() + run: | + set -euo pipefail + + # Removes source checkout, node_modules, dist, npm cache, and TMPDIR. + # Keeps the runner's own _work directory intact. + if [ -d "$GITHUB_WORKSPACE" ]; then + find "$GITHUB_WORKSPACE" -mindepth 1 -maxdepth 1 \ + -exec rm -rf -- {} + + fi From 70d41402a24f75a635e0ccb218422f5c26eddd16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20Gr=C3=A6sberg?= Date: Tue, 15 Sep 2026 22:43:39 +0200 Subject: [PATCH 4/9] Fix issues with workflow Contains generated code, generateed using GPT-5.6 Terra High --- .github/workflows/deploy-to-vm.yaml | 85 +++++++++++++++++------------ 1 file changed, 51 insertions(+), 34 deletions(-) diff --git a/.github/workflows/deploy-to-vm.yaml b/.github/workflows/deploy-to-vm.yaml index 39f0026..0223b55 100644 --- a/.github/workflows/deploy-to-vm.yaml +++ b/.github/workflows/deploy-to-vm.yaml @@ -1,45 +1,62 @@ # Created with assistance from GPT-5.6 Terra High name: CI/CD - Deploy to VM + on: - push: - branches: - - main + push: + branches: + - main + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: production-deploy + cancel-in-progress: false jobs: - deploy: - runs-on: [self-hosted] - timeout-minutes: 10 - - steps: - - uses: actions/checkout@v4 - - - name: Install dependencies - run: | - mkdir -p "$TEMPDIR" - npm ci --no-audit --no-fund - - - name: Build app - run: npm run Build - - - name: Deploy app to apache + deploy: + runs-on: [self-hosted] + timeout-minutes: 10 + + env: + SITE_ROOT: /var/www/html/project1 + npm_config_cache: ${{ github.workspace }}/.npm-cache + TMPDIR: ${{ github.workspace }}/.tmp + + steps: + - name: Check out source + uses: actions/checkout@v4 + + - name: Install dependencies + working-directory: vær + run: | + mkdir -p "$TMPDIR" + npm ci --no-audit --no-fund + + - name: Build app + working-directory: vær + run: npm run build + + - name: Deploy app to Apache run: | set -euo pipefail - test -d "/var/www/html/project1" - test -f dist/index.html + test -d "$SITE_ROOT" + test -f vær/dist/index.html rsync -a --delete --chmod=D755,F644 \ - dist/ "/var/www/html/project1/" - - - name: Cleanup job files - if: always() - run: | - set -euo pipefail - - # Removes source checkout, node_modules, dist, npm cache, and TMPDIR. - # Keeps the runner's own _work directory intact. - if [ -d "$GITHUB_WORKSPACE" ]; then - find "$GITHUB_WORKSPACE" -mindepth 1 -maxdepth 1 \ - -exec rm -rf -- {} + - fi + vær/dist/ "$SITE_ROOT/" + + - name: Clean up job files + if: always() + run: | + set -euo pipefail + + # Removes the checkout, node_modules, dist, npm cache, and TMPDIR. + # Keeps the runner's own _work directory intact. + if [ -d "$GITHUB_WORKSPACE" ]; then + find "$GITHUB_WORKSPACE" -mindepth 1 -maxdepth 1 \ + -exec rm -rf -- {} + + fi From 3d7e57b7238236f5423374e63159122dc3d723bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20Gr=C3=A6sberg?= Date: Wed, 16 Sep 2026 17:28:25 +0200 Subject: [PATCH 5/9] Install and configure prettier --- "v\303\246r/.prettierrc" | 7 +++++-- "v\303\246r/package-lock.json" | 17 +++++++++++++++++ "v\303\246r/package.json" | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) diff --git "a/v\303\246r/.prettierrc" "b/v\303\246r/.prettierrc" index 544b7b4..f6ca428 100644 --- "a/v\303\246r/.prettierrc" +++ "b/v\303\246r/.prettierrc" @@ -1,3 +1,6 @@ { - -} \ No newline at end of file + "trailingComma": "es5", + "tabWidth": 2, + "semi": false, + "singleQuote": false +} diff --git "a/v\303\246r/package-lock.json" "b/v\303\246r/package-lock.json" index 3b7ca00..f28570c 100644 --- "a/v\303\246r/package-lock.json" +++ "b/v\303\246r/package-lock.json" @@ -22,6 +22,7 @@ "eslint-plugin-react-hooks": "^7.1.1", "eslint-plugin-react-refresh": "^0.5.6", "globals": "^17.12.0", + "prettier": "^3.9.7", "typescript": "~6.0.2", "typescript-eslint": "^8.69.0", "vite": "^8.3.0" @@ -2404,6 +2405,22 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.9.7", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.9.7.tgz", + "integrity": "sha512-T3mF5P7HFzZVLDQuCUNtJj6WK1pcpLMweMNUVwGb01bLNkH9AkKxtZvmInw8K6bnn2O3d6/5RHl6zSHiBAD0Og==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", diff --git "a/v\303\246r/package.json" "b/v\303\246r/package.json" index cc694f8..1782863 100644 --- "a/v\303\246r/package.json" +++ "b/v\303\246r/package.json" @@ -24,6 +24,7 @@ "eslint-plugin-react-hooks": "^7.1.1", "eslint-plugin-react-refresh": "^0.5.6", "globals": "^17.12.0", + "prettier": "^3.9.7", "typescript": "~6.0.2", "typescript-eslint": "^8.69.0", "vite": "^8.3.0" From af69429f40ac7511c84a0ddf54554251fe7d1647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20Gr=C3=A6sberg?= Date: Wed, 16 Sep 2026 17:29:04 +0200 Subject: [PATCH 6/9] Remove root level packages --- node_modules/.bin/prettier | 21 --------------------- node_modules/.package-lock.json | 23 ----------------------- package-lock.json | 28 ---------------------------- package.json | 5 ----- 4 files changed, 77 deletions(-) delete mode 100755 node_modules/.bin/prettier delete mode 100644 node_modules/.package-lock.json delete mode 100644 package-lock.json delete mode 100644 package.json diff --git a/node_modules/.bin/prettier b/node_modules/.bin/prettier deleted file mode 100755 index a5a62ae..0000000 --- a/node_modules/.bin/prettier +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") - -case `uname` in - *CYGWIN*|*MINGW*|*MSYS*) - if command -v cygpath > /dev/null 2>&1; then - basedir=`cygpath -w "$basedir"` - fi - ;; -esac - -if [ -z "$NODE_PATH" ]; then - export NODE_PATH="/home/nico/prog/it2810/T09-Project-1/node_modules/.pnpm/prettier@3.9.6/node_modules/prettier/bin/node_modules:/home/nico/prog/it2810/T09-Project-1/node_modules/.pnpm/prettier@3.9.6/node_modules/prettier/node_modules:/home/nico/prog/it2810/T09-Project-1/node_modules/.pnpm/prettier@3.9.6/node_modules:/home/nico/prog/it2810/T09-Project-1/node_modules/.pnpm/node_modules" -else - export NODE_PATH="/home/nico/prog/it2810/T09-Project-1/node_modules/.pnpm/prettier@3.9.6/node_modules/prettier/bin/node_modules:/home/nico/prog/it2810/T09-Project-1/node_modules/.pnpm/prettier@3.9.6/node_modules/prettier/node_modules:/home/nico/prog/it2810/T09-Project-1/node_modules/.pnpm/prettier@3.9.6/node_modules:/home/nico/prog/it2810/T09-Project-1/node_modules/.pnpm/node_modules:$NODE_PATH" -fi -if [ -x "$basedir/node" ]; then - exec "$basedir/node" "$basedir/../prettier/bin/prettier.cjs" "$@" -else - exec node "$basedir/../prettier/bin/prettier.cjs" "$@" -fi diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json deleted file mode 100644 index 2a741c7..0000000 --- a/node_modules/.package-lock.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "T09-Project-1", - "lockfileVersion": 3, - "requires": true, - "packages": { - "node_modules/prettier": { - "version": "3.9.6", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.9.6.tgz", - "integrity": "sha512-OpN0zzVdiaiAhxpuuj5efpIS4sY9j7bY6uR5mnj5yPzGkdkjNKSJeUThPb60Jw29QuAZgA4o+/iB49kFiaBX6g==", - "dev": true, - "license": "MIT", - "bin": { - "prettier": "bin/prettier.cjs" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/prettier/prettier?sponsor=1" - } - } - } -} diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 052b542..0000000 --- a/package-lock.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "T09-Project-1", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "devDependencies": { - "prettier": "3.9.6" - } - }, - "node_modules/prettier": { - "version": "3.9.6", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.9.6.tgz", - "integrity": "sha512-OpN0zzVdiaiAhxpuuj5efpIS4sY9j7bY6uR5mnj5yPzGkdkjNKSJeUThPb60Jw29QuAZgA4o+/iB49kFiaBX6g==", - "dev": true, - "license": "MIT", - "bin": { - "prettier": "bin/prettier.cjs" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/prettier/prettier?sponsor=1" - } - } - } -} diff --git a/package.json b/package.json deleted file mode 100644 index 8dfd824..0000000 --- a/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "devDependencies": { - "prettier": "3.9.6" - } -} From 0093909dc6853c439c7bb414bcd0ee8fc4814bdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20Gr=C3=A6sberg?= Date: Wed, 16 Sep 2026 17:29:59 +0200 Subject: [PATCH 7/9] Create workflow to check linting and formatting on PRs --- .github/workflows/lint-and-format.yaml | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/lint-and-format.yaml diff --git a/.github/workflows/lint-and-format.yaml b/.github/workflows/lint-and-format.yaml new file mode 100644 index 0000000..3cff615 --- /dev/null +++ b/.github/workflows/lint-and-format.yaml @@ -0,0 +1,37 @@ +name: CI/CD - Run lint and formatting checkout + +on: + push: + branches: + - main + pull-request: + types: + - opened + +jobs: + deploy: + runs-on: [self-hosted] + timeout-minutes: 10 + + env: + SITE_ROOT: /var/www/html/project1 + npm_config_cache: ${{ github.workspace }}/.npm-cache + TMPDIR: ${{ github.workspace }}/.tmp + + steps: + - name: Check out source + uses: actions/checkout@v4 + + - name: Install dependencies + working-directory: vær + run: | + mkdir -p "$TMPDIR" + npm ci --no-audit --no-fund + + - name: Run Prettier check + working-directory: vær + run: npx exec prettier . --check + + - name: Run ESLint + working-directory: vær + run: npm run lint From b467b9f495cef5f930919684ec80f3d60036097d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20Gr=C3=A6sberg?= Date: Wed, 16 Sep 2026 17:32:37 +0200 Subject: [PATCH 8/9] Update deploy workflow to only run if linter and formatter checks succeed --- .github/workflows/deploy-to-vm.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-to-vm.yaml b/.github/workflows/deploy-to-vm.yaml index 0223b55..10aa960 100644 --- a/.github/workflows/deploy-to-vm.yaml +++ b/.github/workflows/deploy-to-vm.yaml @@ -3,10 +3,11 @@ name: CI/CD - Deploy to VM on: - push: + workflow_run: + workflows: ["CI/CD - Run lint and formatting checkout"] + types: [completed] branches: - main - workflow_dispatch: permissions: contents: read @@ -17,6 +18,7 @@ concurrency: jobs: deploy: + if: ${{ github.event.workflow_run.conclusion == 'success' }} runs-on: [self-hosted] timeout-minutes: 10 @@ -28,6 +30,8 @@ jobs: steps: - name: Check out source uses: actions/checkout@v4 + with: + ref: ${{ github.event.workflow_run.head_sha }} - name: Install dependencies working-directory: vær From af562eb5bf391657102358b0ef39784920069580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20Gr=C3=A6sberg?= Date: Wed, 16 Sep 2026 17:35:36 +0200 Subject: [PATCH 9/9] Fix yaml formatting --- .github/workflows/lint-and-format.yaml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/lint-and-format.yaml b/.github/workflows/lint-and-format.yaml index 3cff615..b8d2c3c 100644 --- a/.github/workflows/lint-and-format.yaml +++ b/.github/workflows/lint-and-format.yaml @@ -1,15 +1,15 @@ name: CI/CD - Run lint and formatting checkout on: - push: - branches: - - main - pull-request: - types: - - opened + push: + branches: + - main + pull_request: + types: + - opened jobs: - deploy: + deploy: runs-on: [self-hosted] timeout-minutes: 10 @@ -28,10 +28,10 @@ jobs: mkdir -p "$TMPDIR" npm ci --no-audit --no-fund - - name: Run Prettier check - working-directory: vær - run: npx exec prettier . --check + - name: Run Prettier check + working-directory: vær + run: npx exec prettier . --check - - name: Run ESLint - working-directory: vær - run: npm run lint + - name: Run ESLint + working-directory: vær + run: npm run lint