From e6f913e7ce8e7f54a2d68b4ea746a6bd044dd35d Mon Sep 17 00:00:00 2001 From: Valery Melou Date: Sun, 14 Jul 2024 21:42:21 +0100 Subject: [PATCH 1/5] chore: setup deploy previews --- .github/workflows/cd.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 0b4cdd0..4d48a54 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -28,6 +28,27 @@ jobs: path: | dist + preview: + if: ${{ github.event.pull_request.base.ref == 'develop' }} + needs: build + runs-on: ubuntu-latest + environment: staging + steps: + - uses: actions/checkout@v4 + + - name: Download build result + uses: actions/download-artifact@v4 + with: + path: dist + name: build-output-${{ github.ref_name }} + + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }} + channelId: preview + projectId: ${{ secrets.FIREBASE_PROJECT_ID }} + staging: if: github.ref == 'refs/heads/develop' needs: build From 47ef50d4ef650507f76a4240fdee080c3a7bf6ac Mon Sep 17 00:00:00 2001 From: Valery Melou Date: Sun, 14 Jul 2024 21:44:50 +0100 Subject: [PATCH 2/5] chore: set staging deploys as live --- .github/workflows/cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 4d48a54..07addb4 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -67,7 +67,7 @@ jobs: with: repoToken: ${{ secrets.GITHUB_TOKEN }} firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }} - channelId: preview + channelId: live projectId: ${{ secrets.FIREBASE_PROJECT_ID }} production: From dd4ad905d7b3b4e3141634be105b8224e663abfa Mon Sep 17 00:00:00 2001 From: Valery Melou Date: Sun, 14 Jul 2024 21:49:33 +0100 Subject: [PATCH 3/5] chore: fix build condition for previews --- .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 4d4dce3..d5cd60e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,7 @@ jobs: key: ${{ steps.nx-cache-restore.outputs.cache-primary-key }} deploy: - if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || github.event.pull_request.base.ref == 'develop' needs: test uses: ./.github/workflows/cd.yml secrets: inherit From 7e0a205ace928700925d7a1359e509832c5de16d Mon Sep 17 00:00:00 2001 From: Valery Melou Date: Sun, 14 Jul 2024 22:07:09 +0100 Subject: [PATCH 4/5] chore: fix how artifacts are named --- .github/workflows/cd.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 07addb4..3366ae2 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -9,6 +9,8 @@ jobs: VM_CONTENTFUL_SPACE: ${{ secrets.VM_CONTENTFUL_SPACE }} VM_CONTENTFUL_ACCESS_TOKEN: ${{ secrets.VM_CONTENTFUL_ACCESS_TOKEN }} VM_CONTENTFUL_ENVIRONMENT: ${{ github.ref == 'refs/heads/master' && 'production' || 'staging' }} + outputs: + ENVIRONMENT: ${{ github.ref == 'refs/heads/master' && 'production' || 'staging' }} steps: - uses: actions/checkout@v4 @@ -24,7 +26,7 @@ jobs: - name: Archive artifacts uses: actions/upload-artifact@v4 with: - name: build-output-${{ github.ref_name }} + name: build-output-${{ env.ENVIRONMENT }} path: | dist @@ -40,7 +42,7 @@ jobs: uses: actions/download-artifact@v4 with: path: dist - name: build-output-${{ github.ref_name }} + name: build-output-${{ needs.build.outputs.ENVIRONMENT }} - uses: FirebaseExtended/action-hosting-deploy@v0 with: @@ -61,7 +63,7 @@ jobs: uses: actions/download-artifact@v4 with: path: dist - name: build-output-${{ github.ref_name }} + name: build-output-${{ needs.build.outputs.ENVIRONMENT }} - uses: FirebaseExtended/action-hosting-deploy@v0 with: @@ -82,7 +84,7 @@ jobs: uses: actions/download-artifact@v4 with: path: dist - name: build-output-${{ github.ref_name }} + name: build-output-${{ needs.build.outputs.ENVIRONMENT }} - uses: FirebaseExtended/action-hosting-deploy@v0 with: From 5d7349d4429ac0f7912029b8a19dc673859c0ed8 Mon Sep 17 00:00:00 2001 From: Valery Melou Date: Sun, 14 Jul 2024 22:17:05 +0100 Subject: [PATCH 5/5] chore: fix the environment in deploy jobs --- .github/workflows/cd.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 3366ae2..944736f 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -10,7 +10,7 @@ jobs: VM_CONTENTFUL_ACCESS_TOKEN: ${{ secrets.VM_CONTENTFUL_ACCESS_TOKEN }} VM_CONTENTFUL_ENVIRONMENT: ${{ github.ref == 'refs/heads/master' && 'production' || 'staging' }} outputs: - ENVIRONMENT: ${{ github.ref == 'refs/heads/master' && 'production' || 'staging' }} + ENVIRONMENT: ${{ env.VM_CONTENTFUL_ENVIRONMENT }} steps: - uses: actions/checkout@v4 @@ -26,7 +26,7 @@ jobs: - name: Archive artifacts uses: actions/upload-artifact@v4 with: - name: build-output-${{ env.ENVIRONMENT }} + name: build-output-${{ env.VM_CONTENTFUL_ENVIRONMENT }} path: | dist