Skip to content

Commit 09308ec

Browse files
committed
Work CI-CD
- Replace HTTP call to use authenticated request with direct token. ***NO_CI***
1 parent 32a73fa commit 09308ec

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

.pipeline-assets/build-solutions.ps1

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ if ($msbuild) {
1111
$msbuild = join-path $msbuild 'MSBuild\Current\Bin\amd64\MSBuild.exe'
1212
}
1313

14-
# compute authorization header in format "AUTHORIZATION: basic 'encoded token'"
15-
# 'encoded token' is the Base64 of the string "nfbot:personal-token"
16-
$auth = "basic $([System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("nfbot:${env:MY_GITHUBTOKEN}"))))"
14+
# prepare GitHub API headers using token auth
15+
$headers = @{
16+
Authorization = "token $env:MY_GITHUBTOKEN"
17+
'User-Agent' = 'azure-pipelines'
18+
Accept = 'application/vnd.github+json'
19+
}
1720

1821
if($env:System_PullRequest_PullRequestId -ne $null)
1922
{
@@ -30,7 +33,10 @@ if($env:System_PullRequest_PullRequestId -ne $null)
3033
{
3134
"##[debug] INFO: iteration $pageCounter" | Write-Host
3235

33-
$batch = Invoke-RestMethod -Uri "https://api.github.com/repos/nanoframework/Samples/pulls/$env:System_PullRequest_PullRequestNumber/files?per_page=100&page=$pageCounter" -Header @{"Authorization"="$auth"} -ContentType "application/json" -Method GET
36+
$batch = Invoke-RestMethod `
37+
-Uri "https://api.github.com/repos/nanoframework/Samples/pulls/$env:System_PullRequest_PullRequestNumber/files?per_page=100&page=$pageCounter" `
38+
-Headers $headers `
39+
-Method GET
3440

3541
if($null -eq $commit)
3642
{
@@ -63,7 +69,10 @@ else
6369
{
6470
"##[command] Get API file change page: $pageCounter" | Write-Host
6571

66-
$batch = Invoke-RestMethod -Uri "https://api.github.com/repos/nanoframework/Samples/commits/$env:Build_SourceVersion`?per_page=100&page=$pageCounter" -Header @{"Authorization"="$auth"} -ContentType "application/json" -Method GET
72+
$batch = Invoke-RestMethod `
73+
-Uri "https://api.github.com/repos/nanoframework/Samples/commits/$env:Build_SourceVersion`?per_page=100&page=$pageCounter" `
74+
-Headers $headers `
75+
-Method GET
6776

6877
if($null -eq $commit)
6978
{

0 commit comments

Comments
 (0)