From df10421da3986080b44788d4aec877c5915022ef Mon Sep 17 00:00:00 2001 From: Roberto Santalla Date: Thu, 18 May 2023 21:35:58 +0200 Subject: [PATCH 1/3] ci/pr-deploy: remove `update-dependencies` job Both npm and node_modules cache will be generated by other PRs regardless of this job. --- .github/workflows/pr-deploy.yml | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/.github/workflows/pr-deploy.yml b/.github/workflows/pr-deploy.yml index c26f32b71e..a00aa083bd 100644 --- a/.github/workflows/pr-deploy.yml +++ b/.github/workflows/pr-deploy.yml @@ -15,28 +15,8 @@ on: branches: main jobs: - update-dependencies: - name: Update node module dependencies - runs-on: ubuntu-latest - steps: - - name: Checkout project - uses: actions/checkout@v2 - - name: Use Node.js 16.xs - uses: actions/setup-node@v2 - with: - node-version: '16.x' - registry-url: 'https://registry.npmjs.org' - cache: 'npm' - - name: Restore cache - uses: actions/cache@v2 - with: - path: '**/node_modules' - key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }} - - name: Install dependencies - run: npm install lint: name: Lint code - needs: [update-dependencies] runs-on: ubuntu-latest steps: - name: Checkout project From 96535eb730c35db17ccc12ab29f3f014247c2c93 Mon Sep 17 00:00:00 2001 From: Roberto Santalla Date: Thu, 18 May 2023 21:36:52 +0200 Subject: [PATCH 2/3] ci/pr-deploy: coalesce build and deploy jobs By doing this, we remove the need to upload the build output as a GH artifact as an intermediary step. --- .github/workflows/pr-deploy.yml | 40 ++++++++++++--------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/.github/workflows/pr-deploy.yml b/.github/workflows/pr-deploy.yml index a00aa083bd..44ba4e355d 100644 --- a/.github/workflows/pr-deploy.yml +++ b/.github/workflows/pr-deploy.yml @@ -57,7 +57,7 @@ jobs: fail_on_error: true vale_flags: '--glob=**/{docs,translated-guides/en}/**/*.md' build: - name: Build pull request + name: Build and deploy pull request runs-on: ubuntu-latest needs: lint steps: @@ -97,47 +97,35 @@ jobs: - name: Build run: npm run build - - name: Upload artifact - uses: actions/upload-artifact@v2 - with: - name: k6-docs - path: public/ - retention-days: 1 - - deploy: - name: Deploy pull request - runs-on: ubuntu-latest - needs: [build] - if: github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' - env: - AWS_ACCESS_KEY_ID: ${{ secrets.PR_CI_AWS_ACCESS_KEY }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.PR_CI_AWS_SECRET_KEY }} - AWS_REGION: 'eu-west-1' - - steps: - - name: Download artifact - uses: actions/download-artifact@v2 - with: - name: k6-docs - path: public/ - - name: Sync to S3 + id: upload + # Run only if PR does not come from a fork and it is not from dependabot. + if: github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' uses: jakejarvis/s3-sync-action@v0.5.1 with: args: --delete env: + AWS_ACCESS_KEY_ID: ${{ secrets.PR_CI_AWS_ACCESS_KEY }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.PR_CI_AWS_SECRET_KEY }} + AWS_REGION: 'eu-west-1' AWS_S3_BUCKET: ${{ secrets.PR_CI_AWS_S3_BUCKET }} SOURCE_DIR: public/ DEST_DIR: docs/${{ github.ref }} - name: Invalidate Cloudfront + # Run only if we did not skip the upload step + if: steps.upload.outcome == 'success' uses: chetan/invalidate-cloudfront-action@v1.2 env: + AWS_ACCESS_KEY_ID: ${{ secrets.PR_CI_AWS_ACCESS_KEY }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.PR_CI_AWS_SECRET_KEY }} + AWS_REGION: 'eu-west-1' DISTRIBUTION: ${{ secrets.PR_CI_CLOUDFRONT_DISTRIBUTION_ID }} PATHS: '/docs/*' - name: Post published URL to PR - if: github.event.action == 'opened' + # Run only if we did not skip the upload step and it's the first run for this PR. + if: steps.upload.outcome == 'success' && github.event.action == 'opened' uses: actions/github-script@0.8.0 with: github-token: ${{secrets.GITHUB_TOKEN}} From 5553c6562777048044595610740e601ac64a4345 Mon Sep 17 00:00:00 2001 From: Roberto Santalla Date: Mon, 22 May 2023 11:46:28 +0200 Subject: [PATCH 3/3] ci/pr-deploy: restore node_modules cache on build job --- .github/workflows/pr-deploy.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/pr-deploy.yml b/.github/workflows/pr-deploy.yml index 44ba4e355d..05e66e7ba7 100644 --- a/.github/workflows/pr-deploy.yml +++ b/.github/workflows/pr-deploy.yml @@ -78,6 +78,12 @@ jobs: registry-url: 'https://registry.npmjs.org' cache: 'npm' + - name: Restore node_modules cache + uses: actions/cache@v2 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }} + - name: Install run: npm install