From 6fee3df16e36f859a893adcb1c9e5296a9deaa72 Mon Sep 17 00:00:00 2001 From: Greg Frasco Date: Fri, 23 Aug 2024 14:16:34 -0400 Subject: [PATCH] feat: test deployment --- .github/workflows/build.yaml | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 755bd72..5220b21 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -19,6 +19,7 @@ jobs: - name: Authenticate with Google Cloud uses: google-github-actions/auth@v2 + #if: github.event_name == 'push' && github.ref == 'refs/heads/main' with: project_id: sail-intact workload_identity_provider: projects/695814629538/locations/global/workloadIdentityPools/github/providers/github @@ -46,4 +47,29 @@ jobs: run: npm install - name: Build - run: npm run build \ No newline at end of file + run: npm run build + + - name: Backup existing bucket contents + #if: success() && github.ref == 'refs/heads/main' + run: | + gsutil mv gs://intact-frontend/** gs://intact-frontend/backup/ + echo "backup_done=true" >> $GITHUB_ENV + + - name: Deploy to Google Cloud Bucket + uses: google-github-actions/upload-cloud-storage@v2 + #if: success() && github.ref == 'refs/heads/main' && env.backup_done == 'true' + with: + path: /dist/ + destination: intact-frontend + parent: false + + - name: Remove backup + #if: success() && github.ref == 'refs/heads/main' && env.backup_done == 'true' + run: | + gsutil rm -r gs://intact-frontend/backup/ + + - name: Restore from backup (on failure) + #if: failure() && github.ref == 'refs/heads/main' && env.backup_done == 'true' + run: | + gsutil mv gs://intact-frontend-backup/** gs://intact-frontend/ + gsutil -m rm -r gs://intact-frontend-backup/