From 5eaf0d039627131f9b18154ab0e6fb21a33b44f3 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Thu, 15 Dec 2022 21:05:13 +0000 Subject: [PATCH] use github token when available --- .github/workflows/vendor.yml | 2 ++ scripts/update.ps1 | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/vendor.yml b/.github/workflows/vendor.yml index 0d3630cf7..1e8aecdb1 100644 --- a/.github/workflows/vendor.yml +++ b/.github/workflows/vendor.yml @@ -30,6 +30,8 @@ jobs: - id: make-changes name: Checking for updates + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | $currentVersion = (Get-Content .\vendor\sources.json | ConvertFrom-Json) . .\scripts\update.ps1 -verbose diff --git a/scripts/update.ps1 b/scripts/update.ps1 index 9eea2190c..1e6ccc1bd 100644 --- a/scripts/update.ps1 +++ b/scripts/update.ps1 @@ -102,6 +102,12 @@ function Fetch-DownloadUrl { $p = $url.Segments.Split([Environment]::NewLine) + $headers = @{} + + if ($($env:GITHUB_TOKEN)) { + $headers["Authorization"] = "token $($env:GITHUB_TOKEN)" + } + # Api server for GitHub $urlHost = "api.github.com" @@ -110,7 +116,7 @@ function Fetch-DownloadUrl { $apiUrl = [uri] (New-Object System.UriBuilder -ArgumentList $url.Scheme, $urlHost, -1, $urlPath).Uri - $info = Invoke-RestMethod -Uri $apiUrl + $info = Invoke-RestMethod -Uri $apiUrl -Headers $headers $downloadLinks = (New-Object System.Collections.Generic.List[System.Object])