Skip to content

Commit

Permalink
Test storing PR number as TAR label
Browse files Browse the repository at this point in the history
Signed-off-by: Timothy Johnson <[email protected]>
  • Loading branch information
t1m0thyj committed Nov 18, 2024
1 parent b02895e commit 898360f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
13 changes: 6 additions & 7 deletions .github/workflows/deploy-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 898360f

Please sign in to comment.