From d37233de7d7b25772923144e84f085b87e546e1c Mon Sep 17 00:00:00 2001 From: Alex Plischke Date: Thu, 29 Aug 2024 13:25:51 -0700 Subject: [PATCH] ci: bucket based previews --- .github/workflows/deploy-pr-preview.yml | 30 +++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-pr-preview.yml b/.github/workflows/deploy-pr-preview.yml index 55601a8653..e18ef68da5 100644 --- a/.github/workflows/deploy-pr-preview.yml +++ b/.github/workflows/deploy-pr-preview.yml @@ -35,8 +35,20 @@ jobs: node-version-file: '.nvmrc' cache: 'npm' + - name: Google Cloud Login + uses: google-github-actions/auth@v2 + with: + credentials_json: '${{ secrets.RUN_SA_KEY_DEV }}' + + - name: Setup Google Cloud SDK + uses: 'google-github-actions/setup-gcloud@v2' + with: + project_id: ${{ secrets.RUN_PROJECT_DEV }} + env: + CLOUDSDK_PYTHON: ${{ env.pythonLocation }}/python + - name: Set Preview Path - run: echo "PREVIEW_PATH=sauce-docs/pr-preview/pr-${{ github.event.number }}" >> "$GITHUB_ENV" + run: echo "PREVIEW_PATH=pr-preview/pr-${{ github.event.number }}" >> "$GITHUB_ENV" - name: Install Dependencies if: github.event.action != 'closed' # Skip if the PR was closed @@ -48,7 +60,17 @@ jobs: run: | npm run build - - name: Deploy PR - uses: rossjrw/pr-preview-action@v1 + - name: Deploy to Bucket + working-directory: build + run: |- + gsutil -m rsync -R -d . ${{ secrets.GCS_DEV_BUCKET }}/${{ env.PREVIEW_PATH }} + + - name: Deploy Message + if: success() + uses: unsplash/comment-on-pr@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - source-dir: ./build/ + msg: | + Deploy preview ready for ${{ github.event.number }}! + https://docs.dev.saucelabs.net/${{ env.PREVIEW_PATH }}