Skip to content

Commit 6aecc54

Browse files
authored
Merge pull request #68 from SunkenInTime/fix/release-desktop-pages-auth
Add Actions token auth for desktop Pages publish
2 parents 943e5ff + 5bd49d1 commit 6aecc54

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

.github/workflows/release-desktop.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ jobs:
7171

7272
- name: Run Desktop Release Script
7373
shell: pwsh
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7476
run: |
7577
$args = @(
7678
"-ExecutionPolicy", "Bypass",

scripts/publish_pages_branch.ps1

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($remoteUrl)) {
2222
throw "Could not resolve git remote URL for '$Remote'."
2323
}
2424

25+
$remoteUri = $null
26+
if ($remoteUrl -match '^https://') {
27+
$remoteUri = [System.Uri]$remoteUrl
28+
}
29+
2530
$versionInfo = Get-VersionInfo -RepoRoot $repoRoot
2631
$tempRoot = Join-Path ([System.IO.Path]::GetTempPath()) ("icarus-pages-" + [System.Guid]::NewGuid().ToString("N"))
2732

@@ -31,6 +36,21 @@ try {
3136
Invoke-RepoCommand -WorkingDirectory $tempRoot -Command "git" -Arguments @("init")
3237
Invoke-RepoCommand -WorkingDirectory $tempRoot -Command "git" -Arguments @("remote", "add", $Remote, $remoteUrl)
3338

39+
if (-not [string]::IsNullOrWhiteSpace($env:GITHUB_TOKEN) -and $null -ne $remoteUri) {
40+
$tokenBytes = [System.Text.Encoding]::ASCII.GetBytes("x-access-token:$($env:GITHUB_TOKEN)")
41+
$tokenHeader = "AUTHORIZATION: basic {0}" -f [System.Convert]::ToBase64String($tokenBytes)
42+
Push-Location $tempRoot
43+
try {
44+
& git config ("http.https://{0}/.extraheader" -f $remoteUri.Host) $tokenHeader
45+
if ($LASTEXITCODE -ne 0) {
46+
throw "Failed to configure authenticated git access for $($remoteUri.Host)."
47+
}
48+
}
49+
finally {
50+
Pop-Location
51+
}
52+
}
53+
3454
$branchExists = $false
3555
$branchProbe = & git -C $repoRoot ls-remote --heads $Remote $Branch 2>$null
3656
if ($LASTEXITCODE -eq 0 -and -not [string]::IsNullOrWhiteSpace(($branchProbe | Out-String).Trim())) {

0 commit comments

Comments
 (0)