Skip to content

Commit 52ace0f

Browse files
fix: use env var instead of secrets context in step if condition
GitHub Actions does not allow 'secrets' context in step if: expressions. Pass the secret as a step env var (_WIN_CSC_LINK) and check it inside the PowerShell script instead — only exports WIN_CSC_LINK to GITHUB_ENV when the cert is actually configured.
1 parent aca6a17 commit 52ace0f

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,22 @@ jobs:
8787
# Set Windows signing env only when the cert secret is actually configured.
8888
# Passing an empty WIN_CSC_LINK causes electron-builder to resolve it as
8989
# a relative path (the workspace root), which breaks the build.
90+
# Note: 'secrets' context cannot be used in step 'if:' expressions,
91+
# so we pass secrets as env vars and check them inside the script.
9092
- name: Configure Windows code signing
91-
if: matrix.platform == 'win' && secrets.WIN_CSC_LINK != ''
93+
if: matrix.platform == 'win'
9294
shell: pwsh
95+
env:
96+
_WIN_CSC_LINK: ${{ secrets.WIN_CSC_LINK }}
97+
_WIN_CSC_KEY_PASSWORD: ${{ secrets.WIN_CSC_KEY_PASSWORD }}
9398
run: |
94-
echo "WIN_CSC_LINK=${{ secrets.WIN_CSC_LINK }}" | Out-File -FilePath $env:GITHUB_ENV -Append
95-
echo "WIN_CSC_KEY_PASSWORD=${{ secrets.WIN_CSC_KEY_PASSWORD }}" | Out-File -FilePath $env:GITHUB_ENV -Append
99+
if (-not [string]::IsNullOrEmpty($env:_WIN_CSC_LINK)) {
100+
"WIN_CSC_LINK=$($env:_WIN_CSC_LINK)" | Out-File -FilePath $env:GITHUB_ENV -Append
101+
"WIN_CSC_KEY_PASSWORD=$($env:_WIN_CSC_KEY_PASSWORD)" | Out-File -FilePath $env:GITHUB_ENV -Append
102+
Write-Host "Windows code signing configured."
103+
} else {
104+
Write-Host "No Windows certificate found — building unsigned."
105+
}
96106
97107
- name: Build & package
98108
env:

0 commit comments

Comments
 (0)