From bf17e672b0d25392d9244283b7f5a93cd53c8b98 Mon Sep 17 00:00:00 2001 From: Aleksandr Chernigin Date: Sun, 25 Feb 2024 00:30:36 +0400 Subject: [PATCH] Add preview channels for PR --- .github/workflows/pull-request.yml | 39 ++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index e41ae2f..c37faa3 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -45,9 +45,10 @@ jobs: path: dist e2e-chrome-tests: - environment: manual + environment: manual_e2e_tests timeout-minutes: 15 runs-on: ubuntu-latest + if: github.event.pull_request.merged == false container: image: cypress/browsers:node-18.16.0-chrome-114.0.5735.133-1-ff-114.0.2-edge-114.0.1823.51-1 options: --user 1001 @@ -96,9 +97,10 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} e2e-chrome-mobile-tests: - environment: manual + environment: manual_e2e_tests timeout-minutes: 15 runs-on: ubuntu-latest + if: github.event.pull_request.merged == false container: image: cypress/browsers:node-18.16.0-chrome-114.0.5735.133-1-ff-114.0.2-edge-114.0.1823.51-1 options: --user 1001 @@ -145,3 +147,36 @@ jobs: TEST_USER_USERNAME: ${{ secrets.TEST_USER_USERNAME_2 }} TEST_USER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD_2 }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + deploy_preview_website: + environment: deploy_preview + needs: [ build ] + runs-on: ubuntu-latest + if: github.event.pull_request.merged == false + steps: + - name: Checkout repository + uses: actions/checkout@main + - name: Download artifact + uses: actions/download-artifact@main + with: + name: dist + path: dist + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: "${{ secrets.GITHUB_TOKEN }}" + firebaseServiceAccount: "${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }}" + expires: 7d + projectId: "${{ secrets.GOOGLE_PROJECT_ID }}" + + delete_preview_website: + runs-on: ubuntu-latest + if: github.event.action == 'closed' && github.event.pull_request.merged == true + steps: + - uses: actions/checkout@v4 + - uses: w9jds/firebase-action@v12.4.0 + with: + # https://github.com/FirebaseExtended/action-hosting-deploy/issues/60 + args: hosting:channel:list | awk -v pr_number="pr${{ github.event.pull_request.number }}" '$0 ~ pr_number { print $2 }' | xargs -I {} firebase hosting:channel:delete {} --force + env: + GCP_SA_KEY: "${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }}" + PROJECT_ID: "${{ secrets.GOOGLE_PROJECT_ID }}"