Skip to content

Commit

Permalink
use readtoken
Browse files Browse the repository at this point in the history
  • Loading branch information
freddydk committed Jan 23, 2025
1 parent b4def6d commit 1d939b6
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Actions/CheckForUpdates/CheckForUpdates.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ $templateUrl = $templateUrl -replace "^(https:\/\/)(www\.)(.*)$", '$1$3'

# TemplateUrl is now always a full url + @ and a branch name

if ($token) {
if ($update -eq 'Y') {
if (-not $token) {
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."
}

# token comes from a secret, base 64 encoded
$token = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($token))

# Get token with read permissions for this and the template repository - if private and in the same organization
Expand All @@ -44,10 +49,8 @@ if ($token) {
$readToken = GetAccessToken -token $token -permissions @{"actions"="read";"contents"="read";"metadata"="read"} -repositories $repositories
}
else {
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."
}
$readToken = $null
# use token directly
$readToken = $token
}

# Use Authenticated API request if possible to avoid the 60 API calls per hour limit
Expand Down

0 comments on commit 1d939b6

Please sign in to comment.