Skip to content

Commit 5cd1123

Browse files
authored
fix(ci): skip windows signing without secrets (#3186)
The fork guard never fired for Dependabot PRs, so Windows builds tried to sign with empty Azure credentials and hung until the 40 minute job timeout. Gate on whether the credential is present instead of matching on trigger type, which covers forks, Dependabot, and any future secret-less trigger on one path. Dependabot pushes its branches into the repo, so head.repo.fork is false, yet its runs only get the Dependabot secrets store and secrets.AZURE_* expand to empty strings. electron-builder 26.15.2 dropped the preflight that used to fail fast on this (electron-userland/electron-builder#9687), so Invoke-TrustedSigning falls through DefaultAzureCredential to an interactive browser login the runner can never answer. The probe step exists because steps[*].if cannot read the secrets context. Scoping the secret to that step keeps it out of every other step in the job.
1 parent 0547d2f commit 5cd1123

1 file changed

Lines changed: 28 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -225,20 +225,40 @@ jobs:
225225
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
226226
continue-on-error: true # release-please github-release will fail when a release-please PR was merged and the tag doesn't exist.
227227

228-
# PR builds from forks cannot access signing secrets. Strip Windows
229-
# Azure Trusted Signing config so the build produces an unsigned .exe
230-
# artifact instead of failing with "Unable to find valid azure env
231-
# field AZURE_TENANT_ID". Signing remains required on pushes to main
232-
# and on PRs opened from branches within ipfs/ipfs-desktop.
228+
# Some PR builds cannot read the signing secrets: forks never get them,
229+
# and Dependabot PRs only get the separate Dependabot secrets store, so
230+
# secrets.AZURE_* expand to empty strings. Probe for the credential
231+
# rather than matching on trigger type, which keeps every secret-less
232+
# case on one code path. The secret stays scoped to this step's env
233+
# because steps[*].if cannot read the secrets context.
234+
- name: Check for Windows signing secrets
235+
id: win-signing
236+
if: runner.os == 'Windows'
237+
shell: bash
238+
env:
239+
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
240+
run: |
241+
if [ -n "$AZURE_TENANT_ID" ]; then
242+
echo "available=true" >> $GITHUB_OUTPUT
243+
else
244+
echo "available=false" >> $GITHUB_OUTPUT
245+
fi
246+
247+
# Without credentials electron-builder still runs Invoke-TrustedSigning,
248+
# whose DefaultAzureCredential chain falls through to an interactive
249+
# browser login and blocks until the job hits timeout-minutes. Dropping
250+
# azureSignOptions keeps the Windows build running and produces an
251+
# unsigned .exe artifact. Signing remains required on pushes to main and
252+
# on PRs from branches within ipfs/ipfs-desktop.
233253
# Uses js-yaml from node_modules (transitive dep of electron-builder,
234254
# installed by the preceding npm ci step) so this works on the
235255
# windows-latest runner where yq is not preinstalled.
236-
- name: Disable Windows code signing on fork PR builds
237-
if: runner.os == 'Windows' && github.event.pull_request.head.repo.fork == true
256+
- name: Disable Windows code signing when signing secrets are unavailable
257+
if: runner.os == 'Windows' && steps.win-signing.outputs.available == 'false'
238258
shell: bash
239259
run: |
240260
node -e "const fs=require('fs'),yaml=require('js-yaml');const d=yaml.load(fs.readFileSync('electron-builder.yml','utf8'));if(d.win)delete d.win.azureSignOptions;fs.writeFileSync('electron-builder.yml',yaml.dump(d));"
241-
echo "::notice::Windows Azure signing skipped: fork PR has no access to signing secrets."
261+
echo "::notice::Windows Azure signing skipped: no access to signing secrets, producing an unsigned build."
242262
243263
- name: Build binaries with electron-builder
244264
uses: paneron/action-electron-builder@14b133702d1b2e9749912051c43ed62b4afe56c8 # v1.8.1

0 commit comments

Comments
 (0)