From ad542a72fc4de2103fea4cacb480abc61edc5d1d Mon Sep 17 00:00:00 2001 From: Paloma Oliveira Date: Fri, 3 May 2024 00:27:49 +0200 Subject: [PATCH] Update deploy-to-production.yml --- .github/workflows/deploy-to-production.yml | 124 ++++++--------------- 1 file changed, 33 insertions(+), 91 deletions(-) diff --git a/.github/workflows/deploy-to-production.yml b/.github/workflows/deploy-to-production.yml index fbcdc5884e..0431604ebd 100644 --- a/.github/workflows/deploy-to-production.yml +++ b/.github/workflows/deploy-to-production.yml @@ -14,8 +14,8 @@ on: env: NO_INDEX: true - ALGOLIA_APP_ID: ${{secrets.ALGOLIA_APP_ID}} - ALGOLIA_KEY: ${{secrets.ALGOLIA_KEY}} + ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }} + ALGOLIA_KEY: ${{ secrets.ALGOLIA_KEY }} jobs: build: @@ -26,128 +26,70 @@ jobs: fetch-depth: 0 - uses: actions/setup-node@v4 with: - node-version: 18 - + node-version: 18 - uses: actions/cache@v2 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 - + run: npm install - uses: actions/cache@v2 id: cache-build with: - path: | - build + path: build key: ${{ runner.os }}-${{ github.sha }} - - name: Run Build if: steps.cache-build.outputs.cache-hit != 'true' - run: | - npm run build + run: npm run build deploy-staging: runs-on: ubuntu-latest - if: ${{ github.ref == 'refs/heads/main' }} - - job_id: - # Add "id-token" with the intended permissions. - permissions: - contents: 'read' - id-token: 'write' + if: github.ref == 'refs/heads/main' + permissions: + contents: read + id-token: write steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: actions/setup-node@v4 with: - node-version: 18 - - name: Install Python - uses: actions/setup-python@v2 - with: - python-version: 3.7 - - run: pip install crcmod - - - id: 'auth' - uses: 'google-github-actions/auth@v2' + node-version: 18 + - uses: google-github-actions/auth@v2 with: - 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' + workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }} + service_account: ${{ secrets.SERVICE_ACCOUNT_EMAIL }} + - uses: google-github-actions/setup-gcloud@v2 with: - version: '>= 290.0.1' - - - uses: actions/cache@v2 - 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 }} + version: '>= 363.0.0' + - run: npm install + - run: npm run build + - run: gsutil -m rsync -R -d . ${{ secrets.GCS_BUCKET }} deploy-production: needs: deploy-staging runs-on: ubuntu-latest - if: ${{ github.ref == 'refs/heads/main' }} - env: - NO_INDEX: false - + if: github.ref == 'refs/heads/main' + permissions: + contents: read + id-token: write steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-node@v41 + - uses: actions/setup-node@v4 with: - node-version: 18 - - name: Install Python - uses: actions/setup-python@v2 + node-version: 18 + - uses: google-github-actions/auth@v2 with: - python-version: 3.7 - - run: pip install crcmod - - - id: 'auth' - uses: 'google-github-actions/auth@v2' + workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }} + service_account: ${{ secrets.SERVICE_ACCOUNT_EMAIL }} + - uses: google-github-actions/setup-gcloud@v2 with: - 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: '>= 290.0.1' - - - name: Install Dependencies -# if: steps.cache-build.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_PROD_BUCKET }} + version: '>= 363.0.0' + - run: npm install + - run: npm run build + - run: gsutil -m rsync -R -d . ${{ secrets.GCS_PROD_BUCKET }}