|
12 | 12 | required: false |
13 | 13 | default: false |
14 | 14 | type: boolean |
15 | | - allow_unreadable_dependabot: |
16 | | - description: Allow a manual release when the Dependabot API is unavailable (requires external alert review) |
17 | | - required: false |
18 | | - default: false |
19 | | - type: boolean |
20 | 15 | push: |
21 | 16 | tags: |
22 | 17 | - 'v*' |
@@ -104,30 +99,32 @@ jobs: |
104 | 99 | shell: pwsh |
105 | 100 | run: .\scripts\audit-licenses.ps1 |
106 | 101 |
|
| 102 | + - name: Release workflow policy guard |
| 103 | + shell: pwsh |
| 104 | + run: .\scripts\assert-release-workflow.ps1 |
| 105 | + |
107 | 106 | - name: Dependabot alert gate |
108 | 107 | shell: pwsh |
109 | 108 | env: |
110 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 109 | + GH_TOKEN: ${{ secrets.DEPENDABOT_ALERTS_TOKEN }} |
111 | 110 | run: | |
112 | | - $allowUnreadable = $false |
113 | | - if ($env:GITHUB_EVENT_NAME -eq 'workflow_dispatch') { |
114 | | - $allowUnreadable = [bool]::Parse("${{ inputs.allow_unreadable_dependabot }}") |
| 111 | + if ([string]::IsNullOrWhiteSpace($env:GH_TOKEN)) { |
| 112 | + throw "DEPENDABOT_ALERTS_TOKEN is not configured. Add a repository secret with Dependabot alerts: Read." |
115 | 113 | } |
116 | | - $alerts = gh api "/repos/$env:GITHUB_REPOSITORY/dependabot/alerts" --paginate 2>$null |
| 114 | +
|
| 115 | + $alertsJson = gh api "/repos/$env:GITHUB_REPOSITORY/dependabot/alerts?state=open&per_page=100" --paginate --slurp 2>$null |
117 | 116 | if ($LASTEXITCODE -ne 0) { |
118 | | - if (-not $allowUnreadable) { |
119 | | - throw "Dependabot alerts API is not readable. Enable Dependabot alerts / security-events read access before publishing." |
120 | | - } |
121 | | - Write-Warning "Dependabot alerts API is unavailable; manual override was explicitly supplied after external alert review." |
122 | | - $global:LASTEXITCODE = 0 |
123 | | - } else { |
124 | | - $critical = @($alerts | ConvertFrom-Json | Where-Object { |
125 | | - $_.state -eq 'open' -and $_.security_advisory.severity -in @('high', 'critical') |
126 | | - }) |
127 | | - if ($critical.Count -gt 0) { |
128 | | - $names = $critical | ForEach-Object { $_.dependency.package.ecosystem + ':' + $_.dependency.package.name } | Sort-Object -Unique |
129 | | - throw "Open high/critical Dependabot alerts block release: $($names -join ', ')" |
130 | | - } |
| 117 | + throw "Dependabot alerts API is not readable with DEPENDABOT_ALERTS_TOKEN." |
| 118 | + } |
| 119 | +
|
| 120 | + $pages = @($alertsJson | ConvertFrom-Json) |
| 121 | + $alerts = @($pages | ForEach-Object { $_ }) |
| 122 | + $critical = @($alerts | Where-Object { |
| 123 | + $_.state -eq 'open' -and $_.security_advisory.severity -in @('high', 'critical') |
| 124 | + }) |
| 125 | + if ($critical.Count -gt 0) { |
| 126 | + $names = $critical | ForEach-Object { $_.dependency.package.ecosystem + ':' + $_.dependency.package.name } | Sort-Object -Unique |
| 127 | + throw "Open high/critical Dependabot alerts block release: $($names -join ', ')" |
131 | 128 | } |
132 | 129 |
|
133 | 130 | - name: Build release artifacts |
|
0 commit comments