Skip to content

Commit f9a5ab9

Browse files
committed
fix: refactor publish workflow to use environment variable for NuGet API key
1 parent 7aa3d42 commit f9a5ab9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

.github/workflows/publishpackage.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
*.psm1
2424
- name: Validate and publish module
2525
shell: pwsh
26+
env:
27+
nugetkey: ${{secrets.NUGETKEY}}
2628
run: |
2729
# Module path and name
2830
$ModulePath = ".\code365scripts.openai"
@@ -112,15 +114,15 @@ jobs:
112114
# 6. Publish module
113115
Write-Host "🚀 Publishing module to PowerShell Gallery..." -ForegroundColor Yellow
114116
try {
115-
Publish-Module -Path $ModulePath -NuGetApiKey "${{ secrets.NUGETKEY }}" -Verbose -Force
117+
Publish-Module -Path $ModulePath -NuGetApiKey $nugetkey -Verbose -Force
116118
Write-Host "🎉 Module published successfully!" -ForegroundColor Green
117119
Write-Host "📦 Module link: https://www.powershellgallery.com/packages/$ModuleName" -ForegroundColor Cyan
118120
}
119121
catch {
120122
Write-Error "❌ Module publishing failed: $_"
121123
Write-Host "📋 Attempting to publish with SkipAutomaticTags..." -ForegroundColor Yellow
122124
try {
123-
Publish-Module -Path $ModulePath -NuGetApiKey "${{ secrets.NUGETKEY }}" -Verbose -Force -SkipAutomaticTags
125+
Publish-Module -Path $ModulePath -NuGetApiKey $nugetkey -Verbose -Force -SkipAutomaticTags
124126
Write-Host "🎉 Module published successfully (with SkipAutomaticTags)!" -ForegroundColor Green
125127
Write-Host "📦 Module link: https://www.powershellgallery.com/packages/$ModuleName" -ForegroundColor Cyan
126128
}

0 commit comments

Comments
 (0)