From 87fe934c2aff111013d650c2c9cf414f4eff79e2 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Thu, 9 Jan 2025 13:00:25 +0900 Subject: [PATCH 1/4] Install firebase-tools via flake --- flake.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flake.nix b/flake.nix index 535327f62..296bafc1f 100644 --- a/flake.nix +++ b/flake.nix @@ -42,6 +42,8 @@ go_1_23 dart-sass + firebase-tools + markdownlint-cli2 yaml-language-server From 6bd62fabcc57cfd35bb7f6002fe4482f3f74f5ef Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Thu, 9 Jan 2025 13:17:38 +0900 Subject: [PATCH 2/4] `firebase init hosting` --- .firebaserc | 5 +++++ firebase.json | 10 ++++++++++ 2 files changed, 15 insertions(+) create mode 100644 .firebaserc create mode 100644 firebase.json diff --git a/.firebaserc b/.firebaserc new file mode 100644 index 000000000..b6b5ab036 --- /dev/null +++ b/.firebaserc @@ -0,0 +1,5 @@ +{ + "projects": { + "default": "pankona-blog" + } +} diff --git a/firebase.json b/firebase.json new file mode 100644 index 000000000..e78293923 --- /dev/null +++ b/firebase.json @@ -0,0 +1,10 @@ +{ + "hosting": { + "public": "public", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ] + } +} From a0dad9a9b2efb81e1ee4df2193098865d3f43f4a Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Thu, 9 Jan 2025 13:19:38 +0900 Subject: [PATCH 3/4] `firebase init hosting:github` and remove the live channel workflow --- .../firebase-hosting-pull-request.yml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/firebase-hosting-pull-request.yml diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml new file mode 100644 index 000000000..aedde4e12 --- /dev/null +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -0,0 +1,21 @@ +# 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 + - run: npm ci && npm run build + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_PANKONA_BLOG }} + projectId: pankona-blog From 13c12e62f36643c64163bbc5fa2a0fd758cb47ef Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Thu, 9 Jan 2025 13:30:11 +0900 Subject: [PATCH 4/4] Adjust firebase staging workflow with current build steps --- .../firebase-hosting-pull-request.yml | 21 ---------- .../workflows/generate_site_and_deploy.yaml | 40 +++++++++++++++---- 2 files changed, 33 insertions(+), 28 deletions(-) delete mode 100644 .github/workflows/firebase-hosting-pull-request.yml diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml deleted file mode 100644 index aedde4e12..000000000 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ /dev/null @@ -1,21 +0,0 @@ -# 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 - - run: npm ci && npm run build - - uses: FirebaseExtended/action-hosting-deploy@v0 - with: - repoToken: ${{ secrets.GITHUB_TOKEN }} - firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_PANKONA_BLOG }} - projectId: pankona-blog diff --git a/.github/workflows/generate_site_and_deploy.yaml b/.github/workflows/generate_site_and_deploy.yaml index 64a2f1425..58e180969 100644 --- a/.github/workflows/generate_site_and_deploy.yaml +++ b/.github/workflows/generate_site_and_deploy.yaml @@ -7,12 +7,6 @@ on: - main pull_request: -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write - # Default to bash defaults: run: @@ -56,7 +50,39 @@ jobs: uses: actions/upload-pages-artifact@v3 with: path: ./public - deploy: + + deploy-staging: + permissions: + checks: write + contents: read + pull-requests: write + runs-on: ubuntu-latest + needs: build + if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository }} + steps: + - uses: actions/checkout@v4 + - name: Download build assets + env: + GH_TOKEN: ${{ github.token }} + run: | + gh run download --repo '${{ github.repository }}' + - name: Extract the downloaded artifact + run: | + mkdir public + tar -xf ./github-pages/artifact.tar -C public + tree ./public + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_PANKONA_BLOG }} + projectId: pankona-blog + + deploy-production: + # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages + permissions: + contents: read + pages: write + id-token: write # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. concurrency: