From 6d5102891bf79f7428eabfd55c4ec1eac923396c Mon Sep 17 00:00:00 2001 From: Paloma Oliveira Date: Fri, 3 May 2024 11:50:24 +0200 Subject: [PATCH] Trying to fix actions deployment --- .github/workflows/deploy-to-production.yml | 108 ++++++++++++++++----- 1 file changed, 83 insertions(+), 25 deletions(-) diff --git a/.github/workflows/deploy-to-production.yml b/.github/workflows/deploy-to-production.yml index 0431604ebd..17873c3f75 100644 --- a/.github/workflows/deploy-to-production.yml +++ b/.github/workflows/deploy-to-production.yml @@ -26,17 +26,20 @@ jobs: fetch-depth: 0 - uses: actions/setup-node@v4 with: - node-version: 18 - - uses: actions/cache@v2 + node-version: 18.x + + - uses: actions/cache@v4 id: cache-npm-packages with: path: | **/node_modules key: ${{ runner.os }}-${{ hashFiles('**/package.json') }} + - name: Install Dependencies if: steps.cache-npm-packages.outputs.cache-hit != 'true' run: npm install - - uses: actions/cache@v2 + + - uses: actions/cache@v4 id: cache-build with: path: build @@ -47,49 +50,104 @@ jobs: deploy-staging: runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' + if: ${{ github.ref == 'refs/heads/main' }} + permissions: - contents: read - id-token: write + contents: 'read' + id-token: 'write' + steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: actions/setup-node@v4 with: - node-version: 18 - - uses: google-github-actions/auth@v2 + node-version: 18.x + + - name: Install Python + uses: actions/setup-python@v2 with: - workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }} - service_account: ${{ secrets.SERVICE_ACCOUNT_EMAIL }} - - uses: google-github-actions/setup-gcloud@v2 + python-version: 3.7 + - run: pip install crcmod + + - name: Auth GCP + uses: 'google-github-actions/auth@v2' with: - version: '>= 363.0.0' - - run: npm install - - run: npm run build - - run: gsutil -m rsync -R -d . ${{ secrets.GCS_BUCKET }} + workload_identity_provider: ${{ secrets.RUN_PROJECT }} + service_account: ${{ secrets.RUN_SA_KEY }} + + - name: 'Set up Cloud SDK' + uses: 'google-github-actions/setup-gcloud@v2' + with: + version: '>= 290.0.1' + + - name: 'Use gcloud CLI' + run: 'gcloud info' + + - uses: actions/cache@v4 + id: cache-build + with: + path: | + build + key: ${{ runner.os }}-${{ github.sha }} + + - name: Install Dependencies + if: steps.cache-npm-packages.outputs.cache-hit != 'true' + run: | + npm install + + - name: Run Build + if: steps.cache-build.outputs.cache-hit != 'true' + run: | + npm run build + + - name: Deploy to Bucket + run: |- + cd build + gsutil -m rsync -R -d . ${{ secrets.GCS_BUCKET }} deploy-production: needs: deploy-staging runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' + if: ${{ github.ref == 'refs/heads/main' }} + env: + NO_INDEX: false + permissions: contents: read id-token: write + steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: actions/setup-node@v4 with: - node-version: 18 - - uses: google-github-actions/auth@v2 + node-version: 18.x + + - name: Auth GCP + uses: 'google-github-actions/auth@v2' with: - workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }} - service_account: ${{ secrets.SERVICE_ACCOUNT_EMAIL }} - - uses: google-github-actions/setup-gcloud@v2 + workload_identity_provider: ${{ secrets.RUN_PROJECT_PROD }} + service_account: ${{ secrets.RUN_SA_KEY_PROD }} + + - name: 'Set up Cloud SDK' + uses: 'google-github-actions/setup-gcloud@v2' with: - version: '>= 363.0.0' - - run: npm install - - run: npm run build - - run: gsutil -m rsync -R -d . ${{ secrets.GCS_PROD_BUCKET }} + version: '>= 290.0.1' + + - name: 'Use gcloud CLI' + run: 'gcloud info' + + - name: Install Dependencies + run: | + npm install + + - name: Run Build + run: | + npm run build + + - name: Deploy to Bucket + run: |- + cd build + gsutil -m rsync -R -d . ${{ secrets.GCS_PROD_BUCKET }}