Skip to content

Remove NuGet secret in condition - #48

Merged
snovak7 merged 3 commits into
mainfrom
47-reusable-workflow-remove-nuget-key-secret-in-a-condition
Apr 30, 2026
Merged

Remove NuGet secret in condition#48
snovak7 merged 3 commits into
mainfrom
47-reusable-workflow-remove-nuget-key-secret-in-a-condition

Conversation

@snovak7

@snovak7 snovak7 commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Closes #47

Summary by Sourcery

Adjust .NET CI workflow conditions and test execution flags for package publishing and test runs.

Enhancements:

  • Run dotnet tests without restore or build in the CI workflow when tests are enabled.
  • Gate NuGet artifact upload on the pack input flag alongside release tagging conditions.
  • Remove the explicit NuGet.org API key presence check from the NuGet.org publish job condition while keeping existing release tag checks.

Summary by CodeRabbit

  • Chores
    • Updated CI/CD workflow testing to skip unnecessary restore and build steps.
    • Refined conditions for NuGet package artifact publishing and job execution logic.

…via input flags, remove NUGET_ORG_KEY requirement
@snovak7 snovak7 self-assigned this Apr 30, 2026
@snovak7 snovak7 linked an issue Apr 30, 2026 that may be closed by this pull request
@sourcery-ai

sourcery-ai Bot commented Apr 30, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

.github workflow tweaks to optimize test execution and adjust NuGet artifact upload/publish conditions by decoupling them from a secret-based guard and tying upload to the pack input.

Flow diagram for updated .NET test step in CI workflow

flowchart TD
  A[Job build] --> B[Step .NET Test]
  B --> C{inputs.test is true?}
  C -- No --> D[Skip test step]
  C -- Yes --> E[Run dotnet test]
  E --> F[Use --no-restore]
  E --> G[Use --no-build]
  E --> H[Use --nologo]
  E --> I[Collect XPlat Code Coverage]
  E --> J[Use test-adapter-path .]
  E --> K[Configure Coverlet output]
  E --> L[Configure Coverlet format]
  E --> M[Configure Coverlet exclude-by-file]
Loading

File-Level Changes

Change Details Files
Optimize test step in dotnet workflow to avoid redundant restore/build during test execution.
  • Add --no-restore flag to dotnet test invocation.
  • Add --no-build flag to dotnet test invocation.
.github/workflows/dotnet-package.yml
Tighten conditions around NuGet artifact upload to respect the pack input flag.
  • Wrap the existing release/tag condition for uploading NuGet artifacts in an additional check for inputs.pack.
  • Preserve prior logic that restricts upload to release events with tags or explicit release tag names.
.github/workflows/dotnet-package.yml
Remove NuGet.org publish job dependency on the NUGET_ORG_KEY secret in the job-level if condition.
  • Drop secrets.NUGET_ORG_KEY from the job-level if expression for the NuGet.org Publish job while keeping the rest of the release/tag and inputs.nuget-publish conditions intact.
.github/workflows/dotnet-package.yml

Assessment against linked issues

Issue Objective Addressed Explanation
#47 Update the reusable workflow so the 'NuGet.org Publish' job no longer references secrets.NUGET_ORG_KEY in its if condition, resolving the Unrecognized named-value: 'secrets' error.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues, and left some high level feedback:

  • The if expressions combining && and || (e.g. for the upload artifact and NuGet.org publish jobs) would be clearer and less error-prone with explicit parentheses around the OR clause, e.g. inputs.pack && (github.event_name == 'release' && github.ref_type == 'tag' || github.event.release.tag_name)inputs.pack && (github.event_name == 'release' && (github.ref_type == 'tag' || github.event.release.tag_name)) (or similar, depending on the intended logic).
  • By removing && secrets.NUGET_ORG_KEY from the publish job condition, the workflow will now start that job even when the secret is missing; consider adding an early dedicated step that checks for the secret and fails with a clear message to make this failure mode more explicit.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `if` expressions combining `&&` and `||` (e.g. for the upload artifact and NuGet.org publish jobs) would be clearer and less error-prone with explicit parentheses around the OR clause, e.g. `inputs.pack && (github.event_name == 'release' && github.ref_type == 'tag' || github.event.release.tag_name)``inputs.pack && (github.event_name == 'release' && (github.ref_type == 'tag' || github.event.release.tag_name))` (or similar, depending on the intended logic).
- By removing `&& secrets.NUGET_ORG_KEY` from the publish job condition, the workflow will now start that job even when the secret is missing; consider adding an early dedicated step that checks for the secret and fails with a clear message to make this failure mode more explicit.

## Individual Comments

### Comment 1
<location path=".github/workflows/dotnet-package.yml" line_range="116-121" />
<code_context>
       - name: .NET Upload NuGet Artifact
         uses: actions/upload-artifact@v7
-        if: ${{ github.event_name == 'release' && github.ref_type == 'tag' || github.event.release.tag_name }}
+        if: ${{ inputs.pack && (github.event_name == 'release' && github.ref_type == 'tag' || github.event.release.tag_name) }}
         with:
           name: nuget
</code_context>
<issue_to_address>
**suggestion:** Clarify boolean precedence in the `if` expression with extra parentheses for maintainability.

This currently relies on GitHub Actions’ `&&`/`||` precedence, which is harder to read and easy to mis-edit. Please group the release condition explicitly, e.g.: `if: ${{ inputs.pack && ((github.event_name == 'release' && github.ref_type == 'tag') || github.event.release.tag_name) }}`.

```suggestion
      - name: .NET Upload NuGet Artifact
        uses: actions/upload-artifact@v7
        if: ${{ inputs.pack && ((github.event_name == 'release' && github.ref_type == 'tag') || github.event.release.tag_name) }}
        with:
          name: nuget
          path: packages/
    name: NuGet.org Publish
    runs-on: ubuntu-latest
    needs: build
    if: ${{ inputs.nuget-publish && ((github.event_name == 'release' && github.ref_type == 'tag') || github.event.release.tag_name) }}
    steps:
```
</issue_to_address>

### Comment 2
<location path=".github/workflows/dotnet-package.yml" line_range="201-203" />
<code_context>
     name: NuGet.org Publish
     runs-on: ubuntu-latest
     needs: build
-    if: ${{ inputs.nuget-publish && (github.event_name == 'release' && github.ref_type == 'tag' || github.event.release.tag_name) && secrets.NUGET_ORG_KEY }}
+    if: ${{ inputs.nuget-publish && (github.event_name == 'release' && github.ref_type == 'tag' || github.event.release.tag_name) }}
     steps:
       # GitHub Download NuGet Artifact [for NuGet.org Repository]
</code_context>
<issue_to_address>
**issue (bug_risk):** Dropping the `secrets.NUGET_ORG_KEY` guard may cause the publish job to run without a configured API key.

Previously this job was skipped when `NUGET_ORG_KEY` was missing, avoiding a failing publish attempt. Now it will run whenever `inputs.nuget-publish` and the release conditions are true, even if the secret isn’t configured. Unless this check has been moved into the publish step, please keep a guard like `&& secrets.NUGET_ORG_KEY` so misconfigurations fail fast and clearly.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread .github/workflows/dotnet-package.yml
Comment thread .github/workflows/dotnet-package.yml
@coderabbitai

coderabbitai Bot commented Apr 30, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@snovak7 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 46 minutes and 25 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e164abad-edbb-4639-832c-9f01bef8163e

📥 Commits

Reviewing files that changed from the base of the PR and between 36ac969 and 37ba740.

📒 Files selected for processing (1)
  • .github/workflows/dotnet-package.yml

Walkthrough

This pull request modifies the dotnet CI/CD workflow by optimizing test execution with skip flags, adding a conditional gate to artifact uploads based on pack inputs, and removing an invalid secrets reference from the nuget-publish job condition to resolve a syntax error.

Changes

Cohort / File(s) Summary
dotnet Workflow Configuration
.github/workflows/dotnet-package.yml
Modified dotnet test invocation to add --no-restore and --no-build flags. Gated artifact upload for NuGet package to require inputs.pack condition. Removed secrets.NUGET_ORG_KEY check from nuget-publish job conditional to eliminate syntax error, keeping only inputs.nuget-publish and release/tag conditions.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related issues

  • Reusable Workflow: Remove NuGet key secret in a condition #47: Reusable Workflow: Remove NuGet key secret in a condition — This PR directly addresses the unrecognized named-value error by removing the secrets.NUGET_ORG_KEY reference from the conditional expression, resolving the syntax error reported in the issue.

Poem

🐰 A workflow so swift, skipping steps to test,
Secrets removed from the conditional fest!
Pack gates now guard each artifact's way,
The CI/CD pipeline runs clean today!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The changes include modifications to test invocation flags and conditional artifact upload logic beyond the primary objective of removing the secrets reference. Verify that changes to --no-restore/--no-build flags and artifact upload conditions are necessary for resolving issue #47, or consider separating them into distinct pull requests.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Remove NuGet secret in condition' accurately summarizes the main change: removing the secrets.NUGET_ORG_KEY reference from the conditional logic in the workflow.
Linked Issues check ✅ Passed The pull request addresses issue #47 by removing the secrets.NUGET_ORG_KEY reference from the nuget-publish job condition, resolving the 'Unrecognized named-value: secrets' error.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 47-reusable-workflow-remove-nuget-key-secret-in-a-condition

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 46 minutes and 25 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/dotnet-package.yml:
- Line 203: The NuGet publish job is gated only by inputs.nuget-publish and
release info, but the package artifact is uploaded only when inputs.pack is
true, causing missing-artifact failures; update the job's if condition to
require inputs.pack as well (i.e., change the if expression that currently
references inputs.nuget-publish to also && inputs.pack) so that the NuGet
publish step (the conditional using inputs.nuget-publish) runs only when packing
was enabled; ensure the logical grouping/parentheses preserve the existing
release/tag checks while adding inputs.pack to the condition.
- Around line 82-84: The dotnet test invocation uses --no-build while the build
was done in Release, so update the dotnet test command to include the explicit
configuration flag (add --configuration Release alongside --no-build) so test
discovery uses the built Release artifacts; modify the existing dotnet test line
to pass --configuration Release when --no-build is present.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 41296269-6f63-411c-8b54-1d014fc93ec2

📥 Commits

Reviewing files that changed from the base of the PR and between 584a100 and 36ac969.

📒 Files selected for processing (1)
  • .github/workflows/dotnet-package.yml

Comment thread .github/workflows/dotnet-package.yml
Comment thread .github/workflows/dotnet-package.yml
@snovak7
snovak7 merged commit e0cec3c into main Apr 30, 2026
3 checks passed
@snovak7
snovak7 deleted the 47-reusable-workflow-remove-nuget-key-secret-in-a-condition branch April 30, 2026 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reusable Workflow: Remove NuGet key secret in a condition

1 participant