File tree Expand file tree Collapse file tree 1 file changed +27
-4
lines changed
Expand file tree Collapse file tree 1 file changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -19,12 +19,35 @@ jobs:
1919 - name : Get latest release tag from Microsoft repo
2020 id : get_latest
2121 shell : pwsh
22+ env :
23+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
2224 run : |
23- $headers = @{ "User-Agent" = "PowerShell" }
24- $response = Invoke-RestMethod -Uri "https://api.github.com/repos/microsoft/Microsoft-Win32-Content-Prep-Tool/releases/latest" -Headers $headers
25+ # Build authenticated headers for GitHub REST API
26+ $headers = @{
27+ "User-Agent" = "PowerShell"
28+ "Authorization" = "Bearer $env:GITHUB_TOKEN"
29+ "Accept" = "application/vnd.github+json"
30+ "X-GitHub-Api-Version" = "2022-11-28"
31+ }
32+
33+ $uri = "https://api.github.com/repos/microsoft/Microsoft-Win32-Content-Prep-Tool/releases/latest"
2534
26- $tagName = $response.tag_name
27- Add-Content -Path $env:GITHUB_OUTPUT -Value "latest_tag=$tagName"
35+ $maxRetries = 5
36+ $delay = 2
37+ for ($i=1; $i -le $maxRetries; $i++) {
38+ try {
39+ $response = Invoke-RestMethod -Uri $uri -Headers $headers -Method GET -TimeoutSec 30
40+ $tagName = $response.tag_name
41+ if (-not $tagName) { throw "Empty tag_name in response." }
42+ Add-Content -Path $env:GITHUB_OUTPUT -Value "latest_tag=$tagName"
43+ break
44+ } catch {
45+ if ($i -eq $maxRetries) { throw }
46+ # Exponential backoff on known transient/rate-limited responses
47+ Start-Sleep -Seconds $delay
48+ $delay = [Math]::Min($delay * 2, 30)
49+ }
50+ }
2851
2952 - name : Read last processed version if exists
3053 id : read_version
You can’t perform that action at this time.
0 commit comments