Skip to content

Commit b4f021c

Browse files
csharpfritzCopilot
andcommitted
fix(ci): use env var pattern for secrets in nuget.yml if condition
The if: secrets.NUGET_API_KEY expression causes workflow file validation failures in GitHub Actions. Use the env var pattern instead: set the secret to an env var, then check env.NUGET_API_KEY in the if condition. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 754a7f6 commit b4f021c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

.github/workflows/nuget.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ jobs:
4141
run: dotnet nuget push ./nupkg/*.nupkg --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
4242

4343
- name: Push to nuget.org
44-
if: ${{ secrets.NUGET_API_KEY != '' }}
45-
run: dotnet nuget push ./nupkg/*.nupkg --source "https://api.nuget.org/v3/index.json" --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate
44+
env:
45+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
46+
if: env.NUGET_API_KEY != ''
47+
run: dotnet nuget push ./nupkg/*.nupkg --source "https://api.nuget.org/v3/index.json" --api-key ${{ env.NUGET_API_KEY }} --skip-duplicate
4648

4749
- name: Upload NuGet package artifact
4850
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)