Skip to content

Commit 4d8e422

Browse files
committed
Remove dependency on docker/login-action
1 parent 9f1fb7a commit 4d8e422

1 file changed

Lines changed: 41 additions & 9 deletions

File tree

.github/workflows/msvc.yml

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ concurrency:
1212

1313
permissions:
1414
contents: read
15+
packages: write
1516

1617
jobs:
1718
build:
1819
runs-on: windows-2025
19-
if: false # currently broken -> see THRIFT-5936
2020
env:
2121
THRIFT_BUILD_DIR: C:\thrift-build
2222

@@ -36,6 +36,20 @@ jobs:
3636
run: |
3737
New-Item -Path $env:THRIFT_BUILD_DIR -ItemType Directory -Force | Out-Null
3838
39+
- name: Configure Docker credential store
40+
shell: pwsh
41+
run: |
42+
$dockerConfig = Join-Path $env:RUNNER_TEMP 'docker-config'
43+
New-Item -Path $dockerConfig -ItemType Directory -Force | Out-Null
44+
45+
if (-not (Get-Command 'docker-credential-wincred.exe' -ErrorAction SilentlyContinue)) {
46+
Write-Error 'docker-credential-wincred.exe is not available on this runner'
47+
exit 1
48+
}
49+
50+
'{"credsStore":"wincred"}' | Out-File -FilePath (Join-Path $dockerConfig 'config.json') -Encoding ascii
51+
"DOCKER_CONFIG=$dockerConfig" | Out-File -FilePath $env:GITHUB_ENV -Append
52+
3953
- name: Set Docker image name
4054
shell: pwsh
4155
env:
@@ -52,22 +66,32 @@ jobs:
5266
5367
- name: Log in to GHCR
5468
if: github.event_name != 'pull_request'
55-
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
56-
with:
57-
registry: ghcr.io
58-
username: ${{ github.actor }}
59-
password: ${{ secrets.GITHUB_TOKEN }}
69+
shell: pwsh
70+
env:
71+
GHCR_USERNAME: ${{ github.actor }}
72+
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
run: |
74+
$env:GHCR_TOKEN | docker login ghcr.io --username $env:GHCR_USERNAME --password-stdin
75+
if ($LASTEXITCODE -ne 0) {
76+
Write-Error "Failed to log in to GHCR"
77+
exit 1
78+
}
6079
6180
- name: Pull cached image
6281
id: pull_cached
6382
continue-on-error: true
64-
timeout-minutes: 10
83+
timeout-minutes: 40
6584
shell: pwsh
6685
run: |
6786
$needBuild = $true
6887
69-
Write-Host "Attempting to pull hash-based tag: $($env:DOCKER_IMAGE):$($env.IMAGE_TAG)"
70-
$output = docker pull "$($env.DOCKER_IMAGE):$($env.IMAGE_TAG)" 2>&1
88+
if ([string]::IsNullOrWhiteSpace($env:DOCKER_IMAGE) -or [string]::IsNullOrWhiteSpace($env:IMAGE_TAG)) {
89+
Write-Error "DOCKER_IMAGE or IMAGE_TAG is empty. DOCKER_IMAGE='$env:DOCKER_IMAGE' IMAGE_TAG='$env:IMAGE_TAG'"
90+
exit 1
91+
}
92+
93+
Write-Host "Attempting to pull hash-based tag: $($env:DOCKER_IMAGE):$($env:IMAGE_TAG)"
94+
$output = docker pull "$($env:DOCKER_IMAGE):$($env:IMAGE_TAG)" 2>&1
7195
$output | Out-Host
7296
7397
if ($LASTEXITCODE -eq 0) {
@@ -147,3 +171,11 @@ jobs:
147171
name: msvc-LastTest-log
148172
path: ${{ env.THRIFT_BUILD_DIR }}\Testing\Temporary\LastTest.log
149173
if-no-files-found: warn
174+
175+
- name: Remove Docker credential store
176+
if: always()
177+
shell: pwsh
178+
run: |
179+
if (-not [string]::IsNullOrWhiteSpace($env:DOCKER_CONFIG) -and (Test-Path $env:DOCKER_CONFIG)) {
180+
Remove-Item $env:DOCKER_CONFIG -Recurse -Force
181+
}

0 commit comments

Comments
 (0)