Skip to content

Commit 18b2212

Browse files
committed
Get GitHub access token from Pipeline endpoint
1 parent 4b74384 commit 18b2212

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

azure-pipelines.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ jobs:
2020
- checkout: self
2121
submodules: true
2222
presteps:
23-
- task: DownloadSecureFile@1
24-
displayName: Download THNETII.Octokit.Test AuthSecrets
23+
- task: thnetii.azuredevops-githubtasklibrary.githubaccesstokentask.githubaccesstokentask@0
24+
displayName: 'Get GitHub Access Token'
2525
inputs:
26-
secureFile: AuthSecrets.json
27-
- task: CopyFiles@2
28-
displayName: Copy THNETII.Octokit.Test AuthSecrets to test directory
29-
inputs:
30-
sourceFolder: $(Agent.TempDirectory)
31-
contents: AuthSecrets.json
32-
targetFolder: $(Build.SourcesDirectory)/test/THNETII.Octokit.Test/Authentication.Test/
33-
overWrite: true
26+
gitHubConnection: thnetii
27+
- pwsh: |
28+
$targetPath = Join-Path $ENV:Build_SourcesDirectory "test/THNETII.Octokit.Test/Authentication.Test/AuthSecrets.json"
29+
$instance = @{
30+
Credentials = @{
31+
Token = $ENV:GitHubAccessToken;
32+
AuthenticationType = "Bearer";
33+
};
34+
} | ConvertTo-Json | Set-Content -Path $targetPath
35+
env:
36+
GitHubAccessToken: $(GitHub.AccessToken)

0 commit comments

Comments
 (0)