From b02895e7f91fdbcb445d9a528dc8c6deb4c4180d Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Mon, 18 Nov 2024 09:36:27 -0500 Subject: [PATCH 1/3] Append PR number to artifact name for preview builds Signed-off-by: Timothy Johnson --- .github/workflows/build-docs.yml | 6 ++---- .github/workflows/deploy-preview.yml | 8 +++++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 335faa4f66..fd97992520 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -74,14 +74,12 @@ jobs: - name: Compress Build Archive if: ${{ steps.deploy.conclusion == 'skipped' }} - run: | - echo "PR_NUMBER=${{ github.event.pull_request.number }}" > build/.env - tar --remove-files --zstd -cf build.tar.zst build + run: tar --remove-files --zstd -cf build.tar.zst build - name: Upload Build Artifact if: ${{ steps.deploy.conclusion == 'skipped' }} uses: actions/upload-artifact@v3 with: - name: preview-build + name: preview-build-${{ github.event.pull_request.number }} path: build.tar.zst retention-days: 1 diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml index 4119744de3..e539c340b8 100644 --- a/.github/workflows/deploy-preview.yml +++ b/.github/workflows/deploy-preview.yml @@ -23,14 +23,16 @@ jobs: with: workflow: build-docs.yml run_id: ${{ github.event.workflow_run.id }} - name: preview-build + name: "preview-build-\\d+" + name_is_regexp: true if_no_artifact_found: warn - name: Extract Build Archive if: ${{ steps.download-artifact.outputs.found_artifact == 'true' }} run: | - tar -xf build.tar.zst && rm build.tar.zst - cat build/.env >> "$GITHUB_ENV" && rm build/.env + artifactName=$(echo '${{ steps.download-artifact.outputs.artifacts }}' | jq -r '.[0].name') + tar -xf $artifactName/build.tar.zst && rm $artifactName/build.tar.zst + echo "PR_NUMBER=$(echo $artifactName | awk -F'-' '{print $NF}')" >> "$GITHUB_ENV" - name: Deploy to Netlify id: deploy From 898360fa186ef4d19fc816e9268cfe4efe415bf8 Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Mon, 18 Nov 2024 13:02:48 -0500 Subject: [PATCH 2/3] Test storing PR number as TAR label Signed-off-by: Timothy Johnson --- .github/workflows/build-docs.yml | 16 ++++++++-------- .github/workflows/deploy-preview.yml | 13 ++++++------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index fd97992520..6b1df8d284 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -36,14 +36,14 @@ jobs: # https://github.com/actions/checkout/issues/520#issuecomment-1320838255 fetch-depth: 2147483647 - - name: Use Node.js LTS - uses: actions/setup-node@v3 + - name: Use Node.js 20 + uses: actions/setup-node@v4 with: - node-version: 18 + node-version: 20 cache: 'npm' - name: Cache Webpack Build - uses: actions/cache@v3 + uses: actions/cache@v4 env: TAR_OPTIONS: "--remove-files" with: @@ -59,7 +59,7 @@ jobs: - name: Deploy to Netlify id: deploy if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }} - uses: nwtgck/actions-netlify@v2 + uses: nwtgck/actions-netlify@v3 with: publish-dir: build production-branch: master @@ -74,12 +74,12 @@ jobs: - name: Compress Build Archive if: ${{ steps.deploy.conclusion == 'skipped' }} - run: tar --remove-files --zstd -cf build.tar.zst build + run: tar --label=${{ github.event.pull_request.number }} --remove-files --zstd -cf build.tar.zst build - name: Upload Build Artifact if: ${{ steps.deploy.conclusion == 'skipped' }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: preview-build-${{ github.event.pull_request.number }} + name: preview-build path: build.tar.zst retention-days: 1 diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml index e539c340b8..fc5ae916dc 100644 --- a/.github/workflows/deploy-preview.yml +++ b/.github/workflows/deploy-preview.yml @@ -19,25 +19,24 @@ jobs: steps: - name: Download Build Artifact id: download-artifact - uses: dawidd6/action-download-artifact@v2 + uses: dawidd6/action-download-artifact@v6 with: workflow: build-docs.yml run_id: ${{ github.event.workflow_run.id }} - name: "preview-build-\\d+" - name_is_regexp: true + name: preview-build if_no_artifact_found: warn - name: Extract Build Archive if: ${{ steps.download-artifact.outputs.found_artifact == 'true' }} run: | - artifactName=$(echo '${{ steps.download-artifact.outputs.artifacts }}' | jq -r '.[0].name') - tar -xf $artifactName/build.tar.zst && rm $artifactName/build.tar.zst - echo "PR_NUMBER=$(echo $artifactName | awk -F'-' '{print $NF}')" >> "$GITHUB_ENV" + tar -xf build.tar.zst + echo "PR_NUMBER=$(tar --test-label -f build.tar.zst)" >> "$GITHUB_ENV" + rm build.tar.zst - name: Deploy to Netlify id: deploy if: ${{ steps.download-artifact.outputs.found_artifact == 'true' }} - uses: nwtgck/actions-netlify@v2 + uses: nwtgck/actions-netlify@v3 with: publish-dir: build production-deploy: false From 62108e78168a6ce6a64cb0139610939f363bc75c Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Mon, 18 Nov 2024 18:56:06 -0500 Subject: [PATCH 3/3] Update deploy-preview.yml Signed-off-by: Timothy Johnson --- .github/workflows/deploy-preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml index fc5ae916dc..50dca1ec48 100644 --- a/.github/workflows/deploy-preview.yml +++ b/.github/workflows/deploy-preview.yml @@ -30,7 +30,7 @@ jobs: if: ${{ steps.download-artifact.outputs.found_artifact == 'true' }} run: | tar -xf build.tar.zst - echo "PR_NUMBER=$(tar --test-label -f build.tar.zst)" >> "$GITHUB_ENV" + printf "PR_NUMBER=%d\n" "$(tar --test-label -f build.tar.zst)" >> "$GITHUB_ENV" rm build.tar.zst - name: Deploy to Netlify