From bce9b3c40f67d84482f40a1de8116fa4672361d3 Mon Sep 17 00:00:00 2001 From: Martin Kleiven Date: Wed, 6 Nov 2024 10:52:17 +0100 Subject: [PATCH 01/12] Add github actions to deploy on git actions --- .github/workflows/firebase-hosting-merge.yml | 19 ++++++++++++++++++ .../firebase-hosting-pull-request.yml | 20 +++++++++++++++++++ .gitignore | 1 - 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/firebase-hosting-merge.yml create mode 100644 .github/workflows/firebase-hosting-pull-request.yml diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml new file mode 100644 index 0000000..bc78e15 --- /dev/null +++ b/.github/workflows/firebase-hosting-merge.yml @@ -0,0 +1,19 @@ +# This file was auto-generated by the Firebase CLI +# https://github.com/firebase/firebase-tools + +name: Deploy to Firebase Hosting on merge +on: + push: + branches: + - main +jobs: + build_and_deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_KAFFE_DIEM }} + channelId: live + projectId: kaffe-diem diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml new file mode 100644 index 0000000..a5b6f91 --- /dev/null +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -0,0 +1,20 @@ +# This file was auto-generated by the Firebase CLI +# https://github.com/firebase/firebase-tools + +name: Deploy to Firebase Hosting on PR +on: pull_request +permissions: + checks: write + contents: read + pull-requests: write +jobs: + build_and_preview: + if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_KAFFE_DIEM }} + projectId: kaffe-diem diff --git a/.gitignore b/.gitignore index 5029ee8..60355bf 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,3 @@ src/pb.d.ts /pocketbase-data .firebase -.github From 0c36b853b4fed17c5c5698f3c67cd9371849aadf Mon Sep 17 00:00:00 2001 From: Martin Kleiven Date: Wed, 6 Nov 2024 11:01:34 +0100 Subject: [PATCH 02/12] Add declaration env for frameworks api --- .github/workflows/firebase-hosting-merge.yml | 2 ++ .github/workflows/firebase-hosting-pull-request.yml | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml index bc78e15..dea62cc 100644 --- a/.github/workflows/firebase-hosting-merge.yml +++ b/.github/workflows/firebase-hosting-merge.yml @@ -17,3 +17,5 @@ jobs: firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_KAFFE_DIEM }} channelId: live projectId: kaffe-diem + env: + FIREBASE_CLI_EXPERIMENTS: webframeworks diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml index a5b6f91..a47865e 100644 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -18,3 +18,6 @@ jobs: repoToken: ${{ secrets.GITHUB_TOKEN }} firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_KAFFE_DIEM }} projectId: kaffe-diem + env: + FIREBASE_CLI_EXPERIMENTS: webframeworks + From cc729d91dacf45422705b1d193bb559c34fc71b6 Mon Sep 17 00:00:00 2001 From: Martin Kleiven Date: Wed, 6 Nov 2024 11:06:44 +0100 Subject: [PATCH 03/12] Upgrade version(s) for checks --- .github/workflows/checks.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index e27bf3b..492f4e7 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -13,12 +13,12 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: "20" + node-version: "22" - name: Install dependencies run: npm ci From 6053bc81cde3562f2fd837956c72c05c5b343559 Mon Sep 17 00:00:00 2001 From: Martin Kleiven Date: Wed, 6 Nov 2024 11:19:07 +0100 Subject: [PATCH 04/12] Simplify code lint checker --- .github/workflows/checks.yml | 19 ++++--------------- package.json | 6 +++--- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 492f4e7..4cbb108 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -20,19 +20,8 @@ jobs: with: node-version: "22" - - name: Install dependencies - run: npm ci + - name: get prettier prettier-plugin-svelte + run: npm i --save-dev prettier-plugin-svelte prettier - - name: Create env file - # Create .env based on secrets and variables defined in GitHub - run: | - touch .env - echo PUBLIC_PB_HOST=${{ vars.PB_HOST }} >> .env - echo PUBLIC_PB_ADMIN_PASSWORD=${{ secrets.PB_ADMIN_PASSWORD }} >> .env - echo PUBLIC_PB_ADMIN_EMAIL=${{ secrets.PB_ADMIN_EMAIL }} >> .env - - # - name: Run npm check - # run: npm run check - - - name: Run npm check:format - run: npm run check:format + - name: Check code style + run: npx prettier --check . diff --git a/package.json b/package.json index b295ffb..38da2a1 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,8 @@ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "lint": "prettier --check . && eslint .", - "format": "prettier --write .", - "check:format": "prettier --check ." + "format": "npx prettier --write .", + "check:format": "npx prettier --check ." }, "devDependencies": { "@sveltejs/adapter-auto": "^3.0.0", @@ -21,7 +21,7 @@ "@types/eslint": "^9.6.0", "autoprefixer": "^10.4.20", "daisyui": "^4.12.13", - "eslint": "^9.0.0", + "eslint": "^9.0.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-svelte": "^2.36.0", "globals": "^15.0.0", From 885f45a32b88dcf0f078eaebf5b592f4a64542d9 Mon Sep 17 00:00:00 2001 From: Martin Kleiven Date: Wed, 6 Nov 2024 11:30:05 +0100 Subject: [PATCH 05/12] Add build step to deploy variants --- .github/workflows/firebase-hosting-merge.yml | 1 + .github/workflows/firebase-hosting-pull-request.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml index dea62cc..ce517e7 100644 --- a/.github/workflows/firebase-hosting-merge.yml +++ b/.github/workflows/firebase-hosting-merge.yml @@ -11,6 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - run: npm ci && npm run build - uses: FirebaseExtended/action-hosting-deploy@v0 with: repoToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml index a47865e..c86d988 100644 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -13,6 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - run: npm ci && npm run build - uses: FirebaseExtended/action-hosting-deploy@v0 with: repoToken: ${{ secrets.GITHUB_TOKEN }} @@ -20,4 +21,3 @@ jobs: projectId: kaffe-diem env: FIREBASE_CLI_EXPERIMENTS: webframeworks - From 1bb7990a56ba240c33682e4ad24d1191a6b0a730 Mon Sep 17 00:00:00 2001 From: Martin Kleiven Date: Wed, 6 Nov 2024 11:43:20 +0100 Subject: [PATCH 06/12] Add required configuration variable to gh secrets --- .github/workflows/firebase-hosting-merge.yml | 1 + .github/workflows/firebase-hosting-pull-request.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml index ce517e7..2af9201 100644 --- a/.github/workflows/firebase-hosting-merge.yml +++ b/.github/workflows/firebase-hosting-merge.yml @@ -14,6 +14,7 @@ jobs: - run: npm ci && npm run build - uses: FirebaseExtended/action-hosting-deploy@v0 with: + PUBLIC_PB_HOST: ${{ secrets.PUBLIC_PB_HOST }} repoToken: ${{ secrets.GITHUB_TOKEN }} firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_KAFFE_DIEM }} channelId: live diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml index c86d988..e31ebbc 100644 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -17,6 +17,7 @@ jobs: - uses: FirebaseExtended/action-hosting-deploy@v0 with: repoToken: ${{ secrets.GITHUB_TOKEN }} + PUBLIC_PB_HOST: ${{ secrets.PUBLIC_PB_HOST }} firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_KAFFE_DIEM }} projectId: kaffe-diem env: From d87c6a437784f359aef6d00388d1d256419655fa Mon Sep 17 00:00:00 2001 From: Martin Kleiven Date: Wed, 6 Nov 2024 11:46:24 +0100 Subject: [PATCH 07/12] oopsie !fixup --- .github/workflows/firebase-hosting-merge.yml | 2 +- .github/workflows/firebase-hosting-pull-request.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml index 2af9201..e9c6062 100644 --- a/.github/workflows/firebase-hosting-merge.yml +++ b/.github/workflows/firebase-hosting-merge.yml @@ -14,10 +14,10 @@ jobs: - run: npm ci && npm run build - uses: FirebaseExtended/action-hosting-deploy@v0 with: - PUBLIC_PB_HOST: ${{ secrets.PUBLIC_PB_HOST }} repoToken: ${{ secrets.GITHUB_TOKEN }} firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_KAFFE_DIEM }} channelId: live projectId: kaffe-diem env: + PUBLIC_PB_HOST: ${{ secrets.PUBLIC_PB_HOST }} FIREBASE_CLI_EXPERIMENTS: webframeworks diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml index e31ebbc..e4709e6 100644 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -17,8 +17,8 @@ jobs: - uses: FirebaseExtended/action-hosting-deploy@v0 with: repoToken: ${{ secrets.GITHUB_TOKEN }} - PUBLIC_PB_HOST: ${{ secrets.PUBLIC_PB_HOST }} firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_KAFFE_DIEM }} projectId: kaffe-diem env: + PUBLIC_PB_HOST: ${{ secrets.PUBLIC_PB_HOST }} FIREBASE_CLI_EXPERIMENTS: webframeworks From 49fd93256387aaf623e361f292874c8a1c839048 Mon Sep 17 00:00:00 2001 From: Martin Kleiven Date: Wed, 6 Nov 2024 11:50:52 +0100 Subject: [PATCH 08/12] Lift env to early action execution --- .github/workflows/firebase-hosting-merge.yml | 6 +++--- .github/workflows/firebase-hosting-pull-request.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml index e9c6062..07ed1cc 100644 --- a/.github/workflows/firebase-hosting-merge.yml +++ b/.github/workflows/firebase-hosting-merge.yml @@ -9,6 +9,9 @@ on: jobs: build_and_deploy: runs-on: ubuntu-latest + env: + PUBLIC_PB_HOST: ${{ secrets.PUBLIC_PB_HOST }} + FIREBASE_CLI_EXPERIMENTS: webframeworks steps: - uses: actions/checkout@v4 - run: npm ci && npm run build @@ -18,6 +21,3 @@ jobs: firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_KAFFE_DIEM }} channelId: live projectId: kaffe-diem - env: - PUBLIC_PB_HOST: ${{ secrets.PUBLIC_PB_HOST }} - FIREBASE_CLI_EXPERIMENTS: webframeworks diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml index e4709e6..53065b3 100644 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -11,6 +11,9 @@ jobs: build_and_preview: if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} runs-on: ubuntu-latest + env: + PUBLIC_PB_HOST: ${{ secrets.PUBLIC_PB_HOST }} + FIREBASE_CLI_EXPERIMENTS: webframeworks steps: - uses: actions/checkout@v4 - run: npm ci && npm run build @@ -19,6 +22,3 @@ jobs: repoToken: ${{ secrets.GITHUB_TOKEN }} firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_KAFFE_DIEM }} projectId: kaffe-diem - env: - PUBLIC_PB_HOST: ${{ secrets.PUBLIC_PB_HOST }} - FIREBASE_CLI_EXPERIMENTS: webframeworks From dade7372b175744ee3639fdca9313f9bf1121217 Mon Sep 17 00:00:00 2001 From: Martin Kleiven Date: Wed, 6 Nov 2024 14:29:45 +0100 Subject: [PATCH 09/12] use npm ci --- .github/workflows/checks.yml | 6 +++--- package.json | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 4cbb108..a23d242 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -20,8 +20,8 @@ jobs: with: node-version: "22" - - name: get prettier prettier-plugin-svelte - run: npm i --save-dev prettier-plugin-svelte prettier + - name: get deps + run: npm ci prettier-plugin-svelte - - name: Check code style + - name: Lint run: npx prettier --check . diff --git a/package.json b/package.json index 38da2a1..b295ffb 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,8 @@ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "lint": "prettier --check . && eslint .", - "format": "npx prettier --write .", - "check:format": "npx prettier --check ." + "format": "prettier --write .", + "check:format": "prettier --check ." }, "devDependencies": { "@sveltejs/adapter-auto": "^3.0.0", @@ -21,7 +21,7 @@ "@types/eslint": "^9.6.0", "autoprefixer": "^10.4.20", "daisyui": "^4.12.13", - "eslint": "^9.0.0", + "eslint": "^9.0.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-svelte": "^2.36.0", "globals": "^15.0.0", From 917641256922d22f4f242a943f69f7ab70ca9759 Mon Sep 17 00:00:00 2001 From: Martin Kleiven Date: Wed, 6 Nov 2024 14:59:58 +0100 Subject: [PATCH 10/12] !fixup --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index a23d242..740b302 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -21,7 +21,7 @@ jobs: node-version: "22" - name: get deps - run: npm ci prettier-plugin-svelte + run: npm ci - name: Lint run: npx prettier --check . From 7ee02b5861d4ff3f2d55ac9993c9e35d0b2f5ed1 Mon Sep 17 00:00:00 2001 From: Martin Kleiven Date: Wed, 6 Nov 2024 15:49:17 +0100 Subject: [PATCH 11/12] Update .github/workflows/checks.yml Co-authored-by: LilleAila <67327023+LilleAila@users.noreply.github.com> --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 740b302..3a3c897 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -23,5 +23,5 @@ jobs: - name: get deps run: npm ci - - name: Lint + - name: Check formatting run: npx prettier --check . From f4ff781327d86d7c2ba0901ca9f0a0c4c1777c91 Mon Sep 17 00:00:00 2001 From: Martin Kleiven Date: Wed, 6 Nov 2024 19:51:39 +0100 Subject: [PATCH 12/12] !fixup --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 3a3c897..e485696 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -24,4 +24,4 @@ jobs: run: npm ci - name: Check formatting - run: npx prettier --check . + run: npm run check:format