5050 steps :
5151 - id : pr
5252 name : Resolve the pull request behind the build
53- uses : actions/github-script@v8
53+ uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
5454 with :
5555 script : |
5656 const run = context.payload.workflow_run;
6565 run_id: run.id,
6666 per_page: 100,
6767 });
68- if (!artifacts.some((artifact) => artifact.name === "js-bundle" && !artifact.expired)) {
69- core.info("The build run produced no js-bundle artifact. Skipping.");
68+ const bundles = artifacts.filter((artifact) => artifact.name === "js-bundle" && !artifact.expired);
69+ if (bundles.length !== 1) {
70+ core.info(`Expected one js-bundle artifact; found ${bundles.length}. Skipping.`);
7071 core.setOutput("eligible", "false");
7172 return;
7273 }
@@ -114,6 +115,7 @@ jobs:
114115 return;
115116 }
116117
118+ core.setOutput("artifact_id", String(bundles[0].id));
117119 core.setOutput("eligible", "true");
118120 core.setOutput("pr_number", String(pull.number));
119121 core.setOutput("head_sha", pull.head.sha);
@@ -124,7 +126,7 @@ jobs:
124126 - id : vouch
125127 name : Check PR author trust
126128 if : steps.pr.outputs.eligible == 'true'
127- uses : mitchellh/vouch/action/check-user@v1
129+ uses : mitchellh/vouch/action/check-user@d66fa29a64600490892131ad87597c30c91fcac4 # v1
128130 with :
129131 user : ${{ steps.pr.outputs.author }}
130132 allow-fail : true
@@ -199,21 +201,33 @@ jobs:
199201 echo "${output}=${value}" >> "$GITHUB_OUTPUT"
200202 done
201203
202- # release-desktop.yml downloads `js-bundle` from its own run, so the PR
203- # build's bundle is re-published under this run. It is copied as data
204- # and never executed here.
205- - name : Download PR JS bundle
204+ # Only the default-branch revision that owns this workflow supplies the
205+ # validator. Never check out the PR in a workflow_run job.
206+ - name : Checkout trusted artifact validator
206207 if : steps.gate.outputs.eligible == 'true'
207- uses : actions/download-artifact@v8
208+ uses : actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
208209 with :
209- name : js-bundle
210- path : ${{ runner.temp }}/js-bundle
211- github-token : ${{ secrets.GITHUB_TOKEN }}
212- run-id : ${{ github.event.workflow_run.id }}
210+ ref : ${{ github.sha }}
211+ persist-credentials : false
212+ sparse-checkout : .github/scripts
213213
214+ # Fetch the archive as bytes. Extracting it over the checkout, even with
215+ # download-artifact, could replace code that runs with signing secrets.
216+ - name : Download and validate PR JS bundle
217+ if : steps.gate.outputs.eligible == 'true'
218+ shell : bash
219+ env :
220+ GH_TOKEN : ${{ github.token }}
221+ ARTIFACT_ID : ${{ steps.pr.outputs.artifact_id }}
222+ run : |
223+ set -euo pipefail
224+ gh api "repos/${GITHUB_REPOSITORY}/actions/artifacts/${ARTIFACT_ID}/zip" > "$RUNNER_TEMP/js-bundle.zip"
225+ python3 .github/scripts/stage-preview-bundle.py "$RUNNER_TEMP/js-bundle.zip" "$RUNNER_TEMP/js-bundle"
226+
227+ # Only validated bundle files cross into the signing job's artifact.
214228 - name : Stage JS bundle for packaging
215229 if : steps.gate.outputs.eligible == 'true'
216- uses : actions/upload-artifact@v7
230+ uses : actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
217231 with :
218232 name : js-bundle
219233 path : ${{ runner.temp }}/js-bundle
@@ -230,10 +244,16 @@ jobs:
230244 group : desktop-macos-preview-${{ needs.resolve.outputs.pr_number }}-build
231245 cancel-in-progress : true
232246 uses : ./.github/workflows/release-desktop.yml
233- secrets : inherit
247+ secrets :
248+ CSC_LINK : ${{ secrets.CSC_LINK }}
249+ CSC_KEY_PASSWORD : ${{ secrets.CSC_KEY_PASSWORD }}
250+ APPLE_API_KEY : ${{ secrets.APPLE_API_KEY }}
251+ APPLE_API_KEY_ID : ${{ secrets.APPLE_API_KEY_ID }}
252+ APPLE_API_ISSUER : ${{ secrets.APPLE_API_ISSUER }}
253+ MACOS_PROVISIONING_PROFILE : ${{ secrets.MACOS_PROVISIONING_PROFILE }}
234254 with :
235255 version : ${{ needs.resolve.outputs.version }}
236- ref : ${{ github.event.repository.default_branch }}
256+ ref : ${{ github.sha }}
237257 release_channel : preview
238258 relay_client_tracing : false
239259 clerk_publishable_key : ${{ needs.resolve.outputs.clerk_publishable_key }}
@@ -270,7 +290,7 @@ jobs:
270290 pull-requests : write
271291 steps :
272292 - name : Download macOS artifacts
273- uses : actions/download-artifact@v8
293+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
274294 with :
275295 name : desktop-mac-arm64
276296 path : release
@@ -362,7 +382,7 @@ jobs:
362382
363383 - name : Comment download link
364384 if : steps.upload.outputs.download_url != ''
365- uses : actions/github-script@v8
385+ uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
366386 env :
367387 PR_NUMBER : ${{ needs.resolve.outputs.pr_number }}
368388 DOWNLOAD_URL : ${{ steps.upload.outputs.download_url }}
@@ -406,7 +426,9 @@ jobs:
406426 issue_number: prNumber,
407427 per_page: 100,
408428 });
409- const existing = comments.find((comment) => comment.body?.includes(marker));
429+ const existing = comments.find(
430+ (comment) => comment.user?.login === "github-actions[bot]" && comment.body?.includes(marker),
431+ );
410432
411433 if (existing) {
412434 await github.rest.issues.updateComment({
@@ -479,7 +501,7 @@ jobs:
479501
480502 - name : Mark the preview comment as removed
481503 if : steps.delete.outputs.removed == 'true'
482- uses : actions/github-script@v8
504+ uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
483505 with :
484506 script : |
485507 const marker = "<!-- desktop-macos-preview -->";
@@ -489,7 +511,9 @@ jobs:
489511 issue_number: context.payload.pull_request.number,
490512 per_page: 100,
491513 });
492- const existing = comments.find((comment) => comment.body?.includes(marker));
514+ const existing = comments.find(
515+ (comment) => comment.user?.login === "github-actions[bot]" && comment.body?.includes(marker),
516+ );
493517 if (!existing) {
494518 return;
495519 }
0 commit comments