From 237cf2f815236f5c522b34a44e3c25e43696d34b Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Tue, 27 Aug 2024 03:16:58 -0700 Subject: [PATCH] fix: Fix deploy pipeline (#2905) * fix: Fix deploy pipeline * Running deploy to prod workflow only when it pushes to main * Naming steps to understand better when checking the flow in the UI * Building for every PR, including workflow changes --------- Co-authored-by: Diego Molina --- .github/workflows/deploy-pr-preview.yml | 25 +++++---- .github/workflows/deploy-to-dev.yml | 6 +-- .github/workflows/deploy-to-production.yml | 62 +++++++++++++--------- .github/workflows/vale-linter.yml | 2 +- 4 files changed, 57 insertions(+), 38 deletions(-) diff --git a/.github/workflows/deploy-pr-preview.yml b/.github/workflows/deploy-pr-preview.yml index cd716123ad..e3d41eef8f 100644 --- a/.github/workflows/deploy-pr-preview.yml +++ b/.github/workflows/deploy-pr-preview.yml @@ -10,7 +10,6 @@ on: - synchronize - closed paths-ignore: - - '.github/**' - '.docsearch/**' - 'README.md' - '.gitpod.yml' @@ -27,26 +26,32 @@ jobs: deploy-pr-preview: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + name: Checkout Repository with: fetch-depth: 0 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v4 + name: Setup Node.js with: node-version: 18.x - - uses: actions/cache@v2 - id: cache-build - with: - path: | - build - key: ${{ runner.os }}-${{ github.sha }} - - uses: actions/cache@v2 + - uses: actions/cache@v4 + name: Cache NPM Packages id: cache-npm-packages with: path: | **/node_modules key: ${{ runner.os }}-${{ hashFiles('**/package.json') }} + - uses: actions/cache@v4 + name: Cache Build + id: cache-build + with: + path: | + build + key: ${{ runner.os }}-${{ github.sha }} + + - name: Set preview path run: echo "PREVIEW_PATH=sauce-docs/pr-preview/pr-${{ github.event.number }}" >> "$GITHUB_ENV" diff --git a/.github/workflows/deploy-to-dev.yml b/.github/workflows/deploy-to-dev.yml index 73c6b6e2e8..6719d8027e 100644 --- a/.github/workflows/deploy-to-dev.yml +++ b/.github/workflows/deploy-to-dev.yml @@ -20,10 +20,10 @@ jobs: deploy-dev: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v4 with: node-version: 18.x - name: Install Python @@ -38,7 +38,7 @@ jobs: project_id: ${{ secrets.RUN_PROJECT_DEV }} service_account_key: ${{ secrets.RUN_SA_KEY_DEV }} - - uses: actions/cache@v2 + - uses: actions/cache@v4 id: cache-build with: path: | diff --git a/.github/workflows/deploy-to-production.yml b/.github/workflows/deploy-to-production.yml index d246092592..6103523c63 100644 --- a/.github/workflows/deploy-to-production.yml +++ b/.github/workflows/deploy-to-production.yml @@ -1,7 +1,6 @@ name: Deploy to Production on: - pull_request: push: branches: - main @@ -21,14 +20,17 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + name: Checkout Repository with: fetch-depth: 0 - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 + name: Setup Node.js with: node-version: 18.x - - uses: actions/cache@v2 + - uses: actions/cache@v4 + name: Cache NPM Packages id: cache-npm-packages with: path: | @@ -40,7 +42,8 @@ jobs: run: | npm install - - uses: actions/cache@v2 + - uses: actions/cache@v4 + name: Cache Build id: cache-build with: path: | @@ -58,10 +61,12 @@ jobs: if: ${{ github.ref == 'refs/heads/main' }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + name: Checkout Repository with: fetch-depth: 0 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v4 + name: Setup Node.js with: node-version: 18.x - name: Install Python @@ -69,6 +74,7 @@ jobs: with: python-version: 3.7 - run: pip install crcmod + name: Install crcmod - name: Set up Cloud SDK uses: 'google-github-actions/setup-gcloud@v0' with: @@ -76,20 +82,22 @@ jobs: project_id: ${{ secrets.RUN_PROJECT }} service_account_key: ${{ secrets.RUN_SA_KEY }} - - uses: actions/cache@v2 - id: cache-build - with: - path: | - build - key: ${{ runner.os }}-${{ github.sha }} - - - uses: actions/cache@v2 + - uses: actions/cache@v4 + name: Cache NPM Packages id: cache-npm-packages with: path: | **/node_modules key: ${{ runner.os }}-${{ hashFiles('**/package.json') }} + - uses: actions/cache@v4 + name: Cache Build + id: cache-build + with: + path: | + build + key: ${{ runner.os }}-${{ github.sha }} + - name: Install Dependencies if: steps.cache-npm-packages.outputs.cache-hit != 'true' run: | @@ -113,10 +121,12 @@ jobs: NO_INDEX: false steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + name: Checkout Repository with: fetch-depth: 0 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v4 + name: Setup Node.js with: node-version: 18.x - name: Install Python @@ -124,26 +134,30 @@ jobs: with: python-version: 3.7 - run: pip install crcmod + name: Install crcmod - name: Set up Cloud SDK uses: 'google-github-actions/setup-gcloud@v0' with: version: '290.0.1' project_id: ${{ secrets.RUN_PROJECT_PROD }} service_account_key: ${{ secrets.RUN_SA_KEY_PROD }} - - uses: actions/cache@v2 - id: cache-build - with: - path: | - build - key: ${{ runner.os }}-${{ github.sha }} - - uses: actions/cache@v2 + - uses: actions/cache@v4 + name: Cache NPM Packages id: cache-npm-packages with: path: | **/node_modules key: ${{ runner.os }}-${{ hashFiles('**/package.json') }} + - uses: actions/cache@v4 + name: Cache Build + id: cache-build + with: + path: | + build + key: ${{ runner.os }}-${{ github.sha }} + - name: Install Dependencies if: steps.cache-build.outputs.cache-hit != 'true' run: | diff --git a/.github/workflows/vale-linter.yml b/.github/workflows/vale-linter.yml index 0c6dd2dd8c..911ae46872 100644 --- a/.github/workflows/vale-linter.yml +++ b/.github/workflows/vale-linter.yml @@ -6,7 +6,7 @@ jobs: name: runner / vale runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: errata-ai/vale-action@reviewdog with: reporter: github-pr-review