Skip to content

Fix NuGet publish workflow failing on invalid/expired API key - #328

Closed
dsn27 with Copilot wants to merge 2 commits into
masterfrom
copilot/fix-failing-github-actions-job
Closed

Fix NuGet publish workflow failing on invalid/expired API key#328
dsn27 with Copilot wants to merge 2 commits into
masterfrom
copilot/fix-failing-github-actions-job

Conversation

Copilot AI commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

The build job fails at the NuGet push step with a 403 when NUGET_API_KEY is invalid, expired, or unset — causing the entire workflow to fail even though the build and pack steps succeed.

Changes

  • Guard push step — added if: ${{ secrets.NUGET_API_KEY }} so the step is skipped (rather than erroring) when the secret is absent or empty
  • Use env var for API key — replaced direct secret interpolation in shell args with env: NUGET_API_KEY + $env:NUGET_API_KEY, avoiding secret exposure in process listings
  • Add --skip-duplicate — prevents hard failure when pushing a version that already exists on nuget.org
- name: Push NuGet package
  if: ${{ secrets.NUGET_API_KEY }}
  env:
    NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
  run: |
    $version = "${{ github.ref_name }}" -replace '^v', ''
    $pkg = Get-ChildItem -Path ./nupkgs -Filter "*$version.nupkg" | Select-Object -First 1
    dotnet nuget push $pkg.FullName --api-key $env:NUGET_API_KEY --source https://api.nuget.org/v3/index.json --skip-duplicate

The NUGET_API_KEY repository secret needs to be renewed in Settings → Secrets → Actions for publishing to resume.

Copilot AI changed the title [WIP] Fix failing GitHub Actions job 'build' Fix NuGet publish workflow failing on invalid/expired API key Jul 3, 2026
Copilot AI requested a review from dsn27 July 3, 2026 05:52
Copilot finished work on behalf of dsn27 July 3, 2026 05:52
@dsn27 dsn27 closed this Jul 3, 2026
@dsn27
dsn27 deleted the copilot/fix-failing-github-actions-job branch July 10, 2026 05:59
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.

2 participants