Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support authenticating as GitHub Apps instead of using Personal Access Tokens #1311

Open
wants to merge 110 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 77 commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
a091a35
Support GitHub App Auth
freddydk Nov 17, 2024
9463f40
catch
freddydk Nov 17, 2024
dd0cbea
10
freddydk Nov 17, 2024
7c7253d
dumps
freddydk Nov 17, 2024
32aab8d
mask multi
freddydk Nov 17, 2024
0c191ab
add message
freddydk Nov 17, 2024
df1c6e6
precommit
freddydk Nov 17, 2024
ff16e55
token exchange
freddydk Nov 18, 2024
add7df9
getreal
freddydk Nov 18, 2024
38b7860
tests
freddydk Nov 18, 2024
af60cca
getreal
freddydk Nov 18, 2024
6f09716
x
freddydk Nov 18, 2024
e3e4968
use real
freddydk Nov 18, 2024
0f9ae18
use real
freddydk Nov 18, 2024
d0157f6
no user
freddydk Nov 18, 2024
f358ab8
use githubOwner
freddydk Nov 18, 2024
936c912
dump
freddydk Nov 18, 2024
945ca71
use repo
freddydk Nov 18, 2024
dae2cdc
no config
freddydk Nov 18, 2024
cd8b221
use repo
freddydk Nov 18, 2024
1524490
fix token
freddydk Nov 18, 2024
28232d6
mask value
freddydk Nov 18, 2024
1402a6f
move
freddydk Nov 18, 2024
9491ba7
use gh
freddydk Nov 18, 2024
9c30d28
remove silent
freddydk Nov 18, 2024
8b10b20
remove line breaks
freddydk Nov 19, 2024
3f1c796
Merge branch 'main' into noPAT
freddydk Nov 19, 2024
e9ee5e8
fix e2e
freddydk Nov 19, 2024
2501a3b
Merge branch 'noPAT' of https://github.com/freddydk/AL-Go into noPAT
freddydk Nov 19, 2024
112ebc3
silent
freddydk Nov 19, 2024
85014aa
use gfh
freddydk Nov 19, 2024
cea8eda
jit
freddydk Nov 19, 2024
9ba3af2
use real token
freddydk Nov 19, 2024
cdd459c
get token for repo
freddydk Nov 19, 2024
d7d440b
inc count
freddydk Nov 19, 2024
cd03ea6
token cache
freddydk Nov 19, 2024
0496032
Merge branch 'main' into noPAT
freddydk Nov 28, 2024
6ab67c5
Merge branch 'main' into noPAT
freddydk Dec 30, 2024
8c84f06
Merge branch 'main' into noPAT
freddydk Jan 12, 2025
270f0ad
reauth
freddydk Jan 12, 2025
cdab137
dumps
freddydk Jan 12, 2025
15723ba
getreal
freddydk Jan 12, 2025
c2692d8
renew
freddydk Jan 12, 2025
c0ff065
set token
freddydk Jan 12, 2025
8290ab5
no auth
freddydk Jan 12, 2025
a788755
do not mask empty
freddydk Jan 12, 2025
632e1ad
2 secrets
freddydk Jan 14, 2025
7c04d8c
e2e bugs
freddydk Jan 14, 2025
81c452b
remove dump
freddydk Jan 14, 2025
55c7a90
dump
freddydk Jan 14, 2025
04742d1
check existingbranch
freddydk Jan 14, 2025
2b3f47d
check
freddydk Jan 14, 2025
5f505e1
update var name
freddydk Jan 15, 2025
65d54a2
use -algoauthapp
freddydk Jan 15, 2025
9184a2f
use e2epat
freddydk Jan 15, 2025
3c7c447
use token
freddydk Jan 15, 2025
62fb73c
use ghtoken
freddydk Jan 15, 2025
a5569cb
use app
freddydk Jan 15, 2025
73178aa
Merge branch 'main' into noPAT
freddydk Jan 15, 2025
926f101
documentation
freddydk Jan 16, 2025
f642f27
release note
freddydk Jan 16, 2025
ff85721
remove line
freddydk Jan 16, 2025
2528f07
Merge branch 'main' into noPAT
freddydk Jan 16, 2025
06bb22f
rename
freddydk Jan 20, 2025
e3c0b87
Merge branch 'main' into noPAT
freddydk Jan 20, 2025
fc0e339
remove dump
freddydk Jan 20, 2025
f72ecf1
Merge branch 'noPAT' of https://github.com/freddydk/AL-Go into noPAT
freddydk Jan 20, 2025
f92b3dc
Merge branch 'main' into noPAT
freddydk Jan 20, 2025
a476091
comment
freddydk Jan 20, 2025
f52be0a
Merge branch 'noPAT' of https://github.com/freddydk/AL-Go into noPAT
freddydk Jan 20, 2025
3bf8de8
Merge branch 'main' into noPAT
freddydk Jan 20, 2025
32ddfd9
Merge branch 'main' into noPAT
freddydk Jan 22, 2025
1d0fdd5
move release note
freddydk Jan 22, 2025
c9415a0
add permissions
freddydk Jan 22, 2025
78e3ee1
trailing spaces
freddydk Jan 22, 2025
8395f83
dump
freddydk Jan 22, 2025
d2a0a5b
Merge branch 'main' into noPAT
mazhelez Jan 22, 2025
9f750ca
fix err
freddydk Jan 23, 2025
87c90f8
remove verbose
freddydk Jan 23, 2025
4604775
get access token on nuget
freddydk Jan 23, 2025
5180a30
allow token to be empty
freddydk Jan 23, 2025
e6f4a8d
all repos
freddydk Jan 23, 2025
eff2cb9
add contents
freddydk Jan 23, 2025
d2fb99f
=
freddydk Jan 23, 2025
4636616
actions read
freddydk Jan 23, 2025
a4204d0
no permissions
freddydk Jan 23, 2025
8238403
add permissions
freddydk Jan 23, 2025
5407dcf
Update Scenarios/Contribute.md
freddydk Jan 23, 2025
00afbb7
Update Scenarios/GhTokenWorkflow.md
freddydk Jan 23, 2025
0100108
Update Scenarios/GhTokenWorkflow.md
freddydk Jan 23, 2025
92a7e6e
use read and write token
freddydk Jan 23, 2025
c49a9f9
release notes
freddydk Jan 23, 2025
d17fef3
Merge branch 'main' into noPAT
freddydk Jan 23, 2025
ec0c203
set writetoken
freddydk Jan 23, 2025
b4def6d
Merge branch 'noPAT' of https://github.com/freddydk/AL-Go into noPAT
freddydk Jan 23, 2025
1d939b6
use readtoken
freddydk Jan 23, 2025
440c60f
link to doc
freddydk Jan 23, 2025
097b445
Update Scenarios/GhTokenWorkflow.md
freddydk Jan 24, 2025
db3ff49
Update Scenarios/GhTokenWorkflow.md
freddydk Jan 24, 2025
c9f7c99
Update Scenarios/GhTokenWorkflow.md
freddydk Jan 24, 2025
55b910a
review
freddydk Jan 24, 2025
ce383fe
added note
freddydk Jan 24, 2025
d43735a
dump
freddydk Jan 24, 2025
a0dc6d4
add help
freddydk Jan 24, 2025
aebff0d
error msg
freddydk Jan 24, 2025
6222970
precommit and CI
freddydk Jan 24, 2025
a368903
revert
freddydk Jan 24, 2025
6013b81
dump cache usage
freddydk Jan 25, 2025
7efaff8
move back
freddydk Jan 25, 2025
eb166e1
remove cache (never used)
freddydk Jan 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/CleanupTempRepos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ jobs:
$errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0
Import-Module (Join-Path "." "e2eTests/e2eTestHelper.psm1") -DisableNameChecking
$owner = '${{ needs.Check.outputs.githubowner }}'
$token = '${{ Secrets.E2EPAT }}'
SetTokenAndRepository -github -githubOwner $owner -token $token -repository ''
$e2epat = '${{ Secrets.E2EPAT }}'
SetTokenAndRepository -github -githubOwner $owner -e2epat $e2epat -repository ''
@(invoke-gh repo list $owner --limit 1000 -silent -returnValue) | ForEach-Object { $_.Split("`t")[0] } | Where-Object { "$_" -like "$owner/tmp*" } | ForEach-Object {
$repo = $_
Write-Host "https://github.com/$repo"
Expand Down
18 changes: 11 additions & 7 deletions .github/workflows/E2E.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ jobs:
Write-Host "::Error::In order to run end to end tests, you need a Secret called E2EPAT containing a valid Personal Access Token with the following permissions: admin:org, delete_repo, repo, workflow, packages:write"
$err = $true
}
if ('${{ Secrets.ALGOAUTHAPP }}' -eq '') {
Write-Host "::Error::In order to run end to end tests, you need a Secret called ALGOAUTHAPP containing a json structure as described in this app: https://github.com/organizations/BusinessCentralApps/settings/apps/al-go-authentication"
$err = $true
}
if ('${{ Secrets.adminCenterApiCredentials }}' -eq '') {
Write-Host "::Error::In order to run end to end tests, you need a Secret called adminCenterApiCredentials containing API access credentials for BC Admin Center"
$err = $true
Expand Down Expand Up @@ -113,7 +117,7 @@ jobs:
id: setup
run: |
$errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0
. (Join-Path "." "e2eTests/SetupRepositories.ps1") -githubOwner '${{ needs.Check.outputs.githubowner }}' -token '${{ Secrets.E2EPAT }}' -bcContainerHelperVersion '${{ github.event.inputs.bcContainerHelperVersion }}'
. (Join-Path "." "e2eTests/SetupRepositories.ps1") -githubOwner '${{ needs.Check.outputs.githubowner }}' -e2epat '${{ Secrets.E2EPAT }}' -bcContainerHelperVersion '${{ github.event.inputs.bcContainerHelperVersion }}'

Analyze:
runs-on: [ ubuntu-latest ]
Expand Down Expand Up @@ -226,7 +230,7 @@ jobs:
- name: Run test on Windows
run: |
try {
. (Join-Path "." "e2eTests/scenarios/${{ matrix.scenario }}/runtest.ps1") -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -repoName '${{ steps.calculateParams.outputs.repoName }}' -token '${{ Secrets.E2EPAT }}' -pteTemplate '${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.perTenantExtensionRepo }}' -appSourceTemplate '${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.appSourceAppRepo }}' -adminCenterApiToken '${{ Secrets.adminCenterApiCredentials }}'
. (Join-Path "." "e2eTests/scenarios/${{ matrix.scenario }}/runtest.ps1") -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -repoName '${{ steps.calculateParams.outputs.repoName }}' -e2epat '${{ Secrets.E2EPAT }}' -algoauthapp '${{ Secrets.ALGOAUTHAPP }}' -pteTemplate '${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.perTenantExtensionRepo }}' -appSourceTemplate '${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.appSourceAppRepo }}' -adminCenterApiToken '${{ Secrets.adminCenterApiCredentials }}'
}
catch {
Write-Host $_.Exception.Message
Expand Down Expand Up @@ -262,7 +266,7 @@ jobs:
- name: Run tests
run: |
try {
. (Join-Path "." "e2eTests/scenarios/${{ matrix.scenario }}/runtest.ps1") -github -linux -githubOwner '${{ needs.Check.outputs.githubowner }}' -repoName '${{ steps.calculateParams.outputs.repoName }}' -token '${{ Secrets.E2EPAT }}' -pteTemplate '${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.perTenantExtensionRepo }}' -appSourceTemplate '${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.appSourceAppRepo }}' -adminCenterApiToken '${{ Secrets.adminCenterApiCredentials }}'
. (Join-Path "." "e2eTests/scenarios/${{ matrix.scenario }}/runtest.ps1") -github -linux -githubOwner '${{ needs.Check.outputs.githubowner }}' -repoName '${{ steps.calculateParams.outputs.repoName }}' -e2epat '${{ Secrets.E2EPAT }}' -algoauthapp '${{ Secrets.ALGOAUTHAPP }}' -pteTemplate '${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.perTenantExtensionRepo }}' -appSourceTemplate '${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.appSourceAppRepo }}' -adminCenterApiToken '${{ Secrets.adminCenterApiCredentials }}'
}
catch {
Write-Host $_.Exception.Message
Expand Down Expand Up @@ -310,7 +314,7 @@ jobs:
- name: Run tests
run: |
try {
. (Join-Path "." "e2eTests/Test-AL-Go.ps1") -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -repoName ${{ steps.calculateParams.outputs.repoName }} -token '${{ Secrets.E2EPAT }}' -template ${{ steps.calculateParams.outputs.template }} -adminCenterApiToken ${{ steps.calculateParams.outputs.adminCenterApiCredentials }} -multiProject:('${{ matrix.style }}' -eq 'multiProject') -appSource:('${{ matrix.type }}' -eq 'appSourceApp') -linux:('${{ matrix.os }}' -eq 'linux') -useCompilerFolder:('${{ matrix.Compiler }}' -eq 'CompilerFolder')
. (Join-Path "." "e2eTests/Test-AL-Go.ps1") -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -repoName ${{ steps.calculateParams.outputs.repoName }} -e2epat '${{ Secrets.E2EPAT }}' -algoauthapp '${{ Secrets.ALGOAUTHAPP }}' -template ${{ steps.calculateParams.outputs.template }} -adminCenterApiToken ${{ steps.calculateParams.outputs.adminCenterApiCredentials }} -multiProject:('${{ matrix.style }}' -eq 'multiProject') -appSource:('${{ matrix.type }}' -eq 'appSourceApp') -linux:('${{ matrix.os }}' -eq 'linux') -useCompilerFolder:('${{ matrix.Compiler }}' -eq 'CompilerFolder')
}
catch {
Write-Host $_.Exception.Message
Expand Down Expand Up @@ -358,7 +362,7 @@ jobs:
- name: Run tests
run: |
try {
. (Join-Path "." "e2eTests/Test-AL-Go.ps1") -private -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -repoName ${{ steps.calculateParams.outputs.repoName }} -token '${{ Secrets.E2EPAT }}' -template ${{ steps.calculateParams.outputs.template }} -adminCenterApiToken ${{ steps.calculateParams.outputs.adminCenterApiCredentials }} -multiProject:('${{ matrix.style }}' -eq 'multiProject') -appSource:('${{ matrix.type }}' -eq 'appSourceApp') -linux:('${{ matrix.os }}' -eq 'linux') -useCompilerFolder:('${{ matrix.Compiler }}' -eq 'CompilerFolder')
. (Join-Path "." "e2eTests/Test-AL-Go.ps1") -private -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -repoName ${{ steps.calculateParams.outputs.repoName }} -e2epat '${{ Secrets.E2EPAT }}' -algoauthapp '${{ Secrets.ALGOAUTHAPP }}' -template ${{ steps.calculateParams.outputs.template }} -adminCenterApiToken ${{ steps.calculateParams.outputs.adminCenterApiCredentials }} -multiProject:('${{ matrix.style }}' -eq 'multiProject') -appSource:('${{ matrix.type }}' -eq 'appSourceApp') -linux:('${{ matrix.os }}' -eq 'linux') -useCompilerFolder:('${{ matrix.Compiler }}' -eq 'CompilerFolder')
}
catch {
Write-Host $_.Exception.Message
Expand Down Expand Up @@ -405,7 +409,7 @@ jobs:
- name: Run tests
run: |
try {
. (Join-Path "." "e2eTests/Test-AL-Go-Upgrade.ps1") -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -repoName ${{ steps.calculateParams.outputs.repoName }} -token '${{ Secrets.E2EPAT }}' -template ${{ steps.calculateParams.outputs.template }} -appSource:('${{ matrix.type }}' -eq 'appSourceApp') -release '${{ matrix.release }}' -contentPath ${{ steps.calculateParams.outputs.contentPath }}
. (Join-Path "." "e2eTests/Test-AL-Go-Upgrade.ps1") -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -repoName ${{ steps.calculateParams.outputs.repoName }} -e2epat '${{ Secrets.E2EPAT }}' -algoauthapp '${{ Secrets.ALGOAUTHAPP }}' -template ${{ steps.calculateParams.outputs.template }} -appSource:('${{ matrix.type }}' -eq 'appSourceApp') -release '${{ matrix.release }}' -contentPath ${{ steps.calculateParams.outputs.contentPath }}
}
catch {
Write-Host $_.Exception.Message
Expand All @@ -431,4 +435,4 @@ jobs:
- name: Remove Repositories
run: |
$errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0
. (Join-Path "." "e2eTests/RemoveRepositories.ps1") -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -token '${{ Secrets.E2EPAT }}' -actionsRepo '${{ needs.SetupRepositories.outputs.actionsRepo }}' -perTenantExtensionRepo '${{ needs.SetupRepositories.outputs.perTenantExtensionRepo }}' -appSourceAppRepo '${{ needs.SetupRepositories.outputs.appSourceAppRepo }}'
. (Join-Path "." "e2eTests/RemoveRepositories.ps1") -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -e2epat '${{ Secrets.E2EPAT }}' -actionsRepo '${{ needs.SetupRepositories.outputs.actionsRepo }}' -perTenantExtensionRepo '${{ needs.SetupRepositories.outputs.perTenantExtensionRepo }}' -appSourceAppRepo '${{ needs.SetupRepositories.outputs.appSourceAppRepo }}'
9 changes: 5 additions & 4 deletions Actions/AL-Go-Helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $defaultCICDPushBranches = @( 'main', 'release/*', 'feature/*' )
$defaultCICDPullRequestBranches = @( 'main' )
$runningLocal = $local.IsPresent
$defaultBcContainerHelperVersion = "preview" # Must be double quotes. Will be replaced by BcContainerHelperVersion if necessary in the deploy step - ex. "https://github.com/organization/navcontainerhelper/archive/refs/heads/branch.zip"
$notSecretProperties = @("Scopes","TenantId","BlobName","ContainerName","StorageAccountName","ServerUrl","ppUserName")
$notSecretProperties = @("Scopes","TenantId","BlobName","ContainerName","StorageAccountName","ServerUrl","ppUserName","GitHubAppClientId")
freddydk marked this conversation as resolved.
Show resolved Hide resolved

$runAlPipelineOverrides = @(
"DockerPull"
Expand Down Expand Up @@ -1341,12 +1341,13 @@ function CloneIntoNewFolder {
$baseFolder = Join-Path ([System.IO.Path]::GetTempPath()) ([Guid]::NewGuid().ToString())
New-Item $baseFolder -ItemType Directory | Out-Null
Set-Location $baseFolder
$serverUri = [Uri]::new($env:GITHUB_SERVER_URL)
$serverUrl = "$($serverUri.Scheme)://$($actor):$($token)@$($serverUri.Host)/$($env:GITHUB_REPOSITORY)"

# Environment variables for hub commands
$env:GITHUB_USER = $actor
$env:GITHUB_TOKEN = $token
$env:GITHUB_TOKEN = GetAccessToken -token $token -permissions @{"actions"="read";"metadata"="read";"contents"="write";"pull_requests"="write"}
freddydk marked this conversation as resolved.
Show resolved Hide resolved

$serverUri = [Uri]::new($env:GITHUB_SERVER_URL)
$serverUrl = "$($serverUri.Scheme)://$($env:GITHUB_USER):$($env:GITHUB_TOKEN)@$($serverUri.Host)/$($env:GITHUB_REPOSITORY)"

# Configure git
invoke-git config --global user.email "[email protected]"
Expand Down
18 changes: 14 additions & 4 deletions Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,26 @@ function GetLatestTemplateSha {
$branch = $templateUrl.Split('@')[1]

try {
Write-Host "Get latest SHA for $templateUrl"
Fixed Show fixed Hide fixed
$response = InvokeWebRequest -Headers $headers -Uri "$apiUrl/branches?per_page=100" -retry
$branchInfo = ($response.content | ConvertFrom-Json) | Where-Object { $_.Name -eq $branch }
} catch {
if ($_.Exception.Message -like "*401*") {
throw "Failed to update AL-Go System Files. Make sure that the personal access token, defined in the secret called GhTokenWorkflow, is not expired and it has permission to update workflows. (Error was $($_.Exception.Message))"
} else {
Write-Host "Exception: $($_.Exception.Message)"
freddydk marked this conversation as resolved.
Show resolved Hide resolved
Fixed Show fixed Hide fixed
if ($_.Exception.Message -like "*Unauthorized*") {
try {
Write-Host "retry without Authorization header"
Fixed Show fixed Hide fixed
$headers.Remove('Authorization')
$response = InvokeWebRequest -Headers $headers -Uri "$apiUrl/branches?per_page=100" -retry
}
catch {
throw "Failed to update AL-Go System Files. Make sure that the personal access token, defined in the secret called GhTokenWorkflow, is not expired and it has permission to update workflows. (Error was $($_.Exception.Message))"
}
}
else {
throw $_.Exception.Message
}
}

$branchInfo = ($response.content | ConvertFrom-Json) | Where-Object { $_.Name -eq $branch }
freddydk marked this conversation as resolved.
Show resolved Hide resolved
if (!$branchInfo) {
throw "$templateUrl doesn't exist"
}
Expand Down
7 changes: 2 additions & 5 deletions Actions/CheckForUpdates/CheckForUpdates.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,12 @@ if ($update -eq 'Y') {
throw "A personal access token with permissions to modify Workflows is needed. You must add a secret called GhTokenWorkflow containing a personal access token. You can Generate a new token from https://github.com/settings/tokens. Make sure that the workflow scope is checked."
}
else {
$token = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($token))
$token = GetAccessToken -token ([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($token))) -permissions @{"actions"="read";"contents"="write";"pull_requests"="write";"workflows"="write"}
}
}

# Use Authenticated API request to avoid the 60 API calls per hour limit
$headers = @{
"Accept" = "application/vnd.github.baptiste-preview+json"
"Authorization" = "Bearer $token"
}
$headers = GetHeaders -token $token

if (-not $templateUrl.Contains('@')) {
$templateUrl += "@main"
Expand Down
2 changes: 1 addition & 1 deletion Actions/Deliver/Deliver.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ foreach ($thisProject in $projectList) {
}
$nuGetServerUrl = $nuGetAccount.ServerUrl
Write-Host $nuGetAccount.ServerUrl
$nuGetToken = $nuGetAccount.Token
$nuGetToken = GetAccessToken -token $nuGetAccount.Token -permissions @{"contents"="read";"metadata"="read";"packages"="write"}
Write-Host "$($deliveryTarget)Context secret OK"
}
catch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
)

function IsGitHubPagesAvailable() {
$headers = GetHeader -token $env:GITHUB_TOKEN
$headers = GetHeaders -token $env:GITHUB_TOKEN
$url = "$($ENV:GITHUB_API_URL)/repos/$($ENV:GITHUB_REPOSITORY)/pages"
try {
Write-Host "Requesting GitHub Pages settings from GitHub"
Expand All @@ -20,7 +20,7 @@ function IsGitHubPagesAvailable() {
}

function GetGitHubEnvironments() {
$headers = GetHeader -token $env:GITHUB_TOKEN
$headers = GetHeaders -token $env:GITHUB_TOKEN
freddydk marked this conversation as resolved.
Show resolved Hide resolved
$url = "$($ENV:GITHUB_API_URL)/repos/$($ENV:GITHUB_REPOSITORY)/environments"
try {
Write-Host "Requesting environments from GitHub"
Expand All @@ -36,7 +36,7 @@ function GetGitHubEnvironments() {
function Get-BranchesFromPolicy($ghEnvironment) {
if ($ghEnvironment) {
# Environment is defined in GitHub - check protection rules
$headers = GetHeader -token $env:GITHUB_TOKEN
$headers = GetHeaders -token $env:GITHUB_TOKEN
$branchPolicy = ($ghEnvironment.protection_rules | Where-Object { $_.type -eq "branch_policy" })
if ($branchPolicy) {
if ($ghEnvironment.deployment_branch_policy.protected_branches) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ function Get-ModifiedFiles {

$url = "$($env:GITHUB_API_URL)/repos/$($env:GITHUB_REPOSITORY)/compare/$($ghEvent.pull_request.base.sha)...$($ghEvent.pull_request.head.sha)"

$headers = @{
"Authorization" = "token $token"
"Accept" = "application/vnd.github.baptiste-preview+json"
}
$headers = GetHeaders -token $token

$response = (InvokeWebRequest -Headers $headers -Uri $url).Content | ConvertFrom-Json

Expand Down
Loading
Loading