Skip to content

Commit e4283ed

Browse files
committed
Skip NuGet push gracefully when NUGET_API_KEY is not configured
Check for secret availability before attempting push to avoid 401 errors on repos without the secret configured. Made-with: Cursor
1 parent 2ceb20c commit e4283ed

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ jobs:
193193
runs-on: ubuntu-latest
194194
timeout-minutes: 15
195195
environment: release
196+
env:
197+
HAS_NUGET_KEY: ${{ secrets.NUGET_API_KEY != '' }}
196198

197199
steps:
198200
- uses: actions/checkout@v6
@@ -255,7 +257,10 @@ jobs:
255257
PY
256258
257259
- name: Push to NuGet.org
260+
if: env.HAS_NUGET_KEY == 'true'
258261
shell: bash
262+
env:
263+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
259264
run: |
260265
shopt -s nullglob
261266
PACKAGES=(packages/*.nupkg)
@@ -267,12 +272,17 @@ jobs:
267272
for pkg in "${PACKAGES[@]}"; do
268273
echo "Pushing $pkg"
269274
dotnet nuget push "$pkg" \
270-
--api-key "${{ secrets.NUGET_API_KEY }}" \
275+
--api-key "$NUGET_API_KEY" \
271276
--source https://api.nuget.org/v3/index.json \
272277
--skip-duplicate
273278
done
274279
echo "All packages pushed to NuGet.org"
275280
281+
- name: NuGet push skipped
282+
if: env.HAS_NUGET_KEY != 'true'
283+
shell: bash
284+
run: echo "::warning::NUGET_API_KEY not configured. Skipping NuGet push."
285+
276286
deploy-docs:
277287
name: Deploy Documentation
278288
needs: [resolve-version, release-packages]

0 commit comments

Comments
 (0)