Skip to content

Commit 45ea872

Browse files
committed
Work CI-CD
- Migrate PS to use invoke rest method. - GitHub auth now using token directly. ***NO_CI***
1 parent 5a5acb5 commit 45ea872

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

.pipeline-assets/pipeline-build-solutions.PS1

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

14-
$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+
}
1520

1621
if($env:DEVICE_TO_BUILD -eq "")
1722
{
@@ -30,7 +35,10 @@ if($env:DEVICE_TO_BUILD -eq "")
3035
{
3136
"##[debug] INFO: iteration $pageCounter" | Write-Host
3237

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

3543
if($null -eq $commit)
3644
{
@@ -63,7 +71,10 @@ if($env:DEVICE_TO_BUILD -eq "")
6371
{
6472
"##[command] Get API file change page: $pageCounter" | Write-Host
6573

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

6879
if($null -eq $commit)
6980
{

0 commit comments

Comments
 (0)