diff --git a/.github/workflows/build-preview.yml b/.github/workflows/build-preview.yml index d7f3e1a2b..9a534f2e2 100644 --- a/.github/workflows/build-preview.yml +++ b/.github/workflows/build-preview.yml @@ -42,20 +42,6 @@ jobs: uses: actions/setup-node@v3 with: node-version: 18.16.1 #18.17.0 is buggy - - name: Save PR number - env: - PR_NUMBER: ${{ github.event.pull_request.number }} - PR_SHA: ${{ github.sha }} - run: | - mkdir -p ./pr - echo $PR_NUMBER > ./pr/pr_number - echo $PR_SHA > ./pr/pr_sha - echo "Saved PR# ${{ github.event.pull_request.number }}, SHA# ${{ github.sha }} for upload" - - name: Save PR# - uses: actions/upload-artifact@v3 - with: - name: pr_number - path: pr/ - name: Install and Build 🔧 run: | npm ci --include=dev @@ -73,10 +59,10 @@ jobs: - name: Compare Stats id: compare-stats run: | - mkdir stats + mkdir -p pr echo '${{ env.MAIN_STATS }}' echo '${{ env.PR_STATS }}' - npm exec ts-node scripts/stats_compare '${{ env.MAIN_STATS }}' '${{ env.PR_STATS }}' > stats/stats-difference.md + npm exec ts-node scripts/stats_compare '${{ env.MAIN_STATS }}' '${{ env.PR_STATS }}' > pr/stats-difference.md - name: Print Stats to GitHub Checks uses: LouisBrunner/checks-action@v1.6.1 if: always() @@ -86,9 +72,22 @@ jobs: conclusion: neutral output: | {"summary":"Style size changes introduced by this PR"} - output_text_description_file: stats/stats-difference.md + output_text_description_file: pr/stats-difference.md - name: Upload Build artifact uses: actions/upload-artifact@v3 with: name: americana path: dist/ + - name: Save PR artifacts + env: + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_SHA: ${{ github.sha }} + run: | + echo $PR_NUMBER > pr/pr_number + echo $PR_SHA > pr/pr_sha + echo "Saved PR# ${{ github.event.pull_request.number }}, SHA# ${{ github.sha }} for upload" + - name: Upload PR artifacts + uses: actions/upload-artifact@v3 + with: + name: pr_ci_artifacts + path: pr/ diff --git a/.github/workflows/s3-upload.yml b/.github/workflows/s3-upload.yml index df7a3319d..beb8ac6b9 100644 --- a/.github/workflows/s3-upload.yml +++ b/.github/workflows/s3-upload.yml @@ -22,7 +22,7 @@ jobs: run_id: context.payload.workflow_run.id, }); let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { - return artifact.name == "pr_number" + return artifact.name == "pr_ci_artifacts" })[0]; let download = await github.rest.actions.downloadArtifact({ owner: context.repo.owner, @@ -31,7 +31,7 @@ jobs: archive_format: 'zip', }); let fs = require('fs'); - fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_number.zip`, Buffer.from(download.data)); + fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_ci_artifacts.zip`, Buffer.from(download.data)); - name: "Download Build" uses: actions/github-script@v6 with: @@ -54,7 +54,7 @@ jobs: fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/americana.zip`, Buffer.from(download.data)); - name: "Unzip artifacts" run: | - unzip pr_number.zip + unzip pr_ci_artifacts.zip unzip -d dist americana.zip - name: Set PR variable run: | @@ -110,12 +110,18 @@ jobs: " > pr_preview.md + - uses: tibdex/github-app-token@v1 + # See https://josh-ops.com/posts/using-github-checks-api/ + id: get_installation_token + with: + app_id: 396440 #osm-americana checks app + private_key: ${{ secrets.CHECKS_WRITER_SECRET }} - name: Print Preview Links to GitHub Checks uses: LouisBrunner/checks-action@v1.6.1 if: always() with: sha: ${{ env.PR_SHA }} - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ steps.get_installation_token.outputs.token }} name: PR Preview conclusion: neutral output: |