Fix release workflow NuGet publish gating for organization secret - #180
Merged
Conversation
Agent-Logs-Url: https://github.com/IoTSharp/SilkierQuartz/sessions/cd92de74-61b8-408e-b2e2-07b7dc865b9e Co-authored-by: maikebing <3445167+maikebing@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
maikebing
April 18, 2026 11:10
View session
maikebing
marked this pull request as ready for review
April 18, 2026 11:11
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the GitHub Actions release workflow to avoid a workflow parsing failure and to conditionally publish NuGet packages only when the NuGet API key is available.
Changes:
- Maps
secrets.NUGET_API_KEYinto thereleasejob environment. - Gates the “Publish to NuGet” step using
env.NUGET_API_KEY != ''. - Switches
dotnet nuget pushto use the mapped environment variable.
Comment on lines
+14
to
+15
| env: | ||
| NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} |
There was a problem hiding this comment.
NUGET_API_KEY is set at the job level, so it will be injected into the environment of all steps (including third-party actions like softprops/action-gh-release). To reduce accidental exposure/supply-chain risk, scope the secret to only the NuGet publish step (move the env: NUGET_API_KEY: ... mapping onto that step) and keep the if: env.NUGET_API_KEY != '' gate there as well.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The release workflow failed to load because it referenced
secrets.NUGET_API_KEYdirectly in a step-levelif, which is not supported in this expression context. This change switches the workflow to consume the organization-level NuGet key through job environment state and uses that value to conditionally publish packages.Problem
NUGET_API_KEYdue to invalidifexpression usage.Workflow change
secrets.NUGET_API_KEYinto thereleasejobenv.env.NUGET_API_KEY != ''instead of referencingsecretsdirectly.dotnet nuget push.Result