Skip to content

Commit ef4909c

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

1 file changed

Lines changed: 43 additions & 9 deletions

File tree

.github/workflows/msvc.yml

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ permissions:
1616
jobs:
1717
build:
1818
runs-on: windows-2025
19-
if: false # currently broken -> see THRIFT-5936
19+
permissions:
20+
contents: read
21+
packages: write
2022
env:
2123
THRIFT_BUILD_DIR: C:\thrift-build
2224

@@ -36,6 +38,20 @@ jobs:
3638
run: |
3739
New-Item -Path $env:THRIFT_BUILD_DIR -ItemType Directory -Force | Out-Null
3840
41+
- name: Configure Docker credential store
42+
shell: pwsh
43+
run: |
44+
$dockerConfig = Join-Path $env:RUNNER_TEMP 'docker-config'
45+
New-Item -Path $dockerConfig -ItemType Directory -Force | Out-Null
46+
47+
if (-not (Get-Command 'docker-credential-wincred.exe' -ErrorAction SilentlyContinue)) {
48+
Write-Error 'docker-credential-wincred.exe is not available on this runner'
49+
exit 1
50+
}
51+
52+
'{"credsStore":"wincred"}' | Out-File -FilePath (Join-Path $dockerConfig 'config.json') -Encoding ascii
53+
"DOCKER_CONFIG=$dockerConfig" | Out-File -FilePath $env:GITHUB_ENV -Append
54+
3955
- name: Set Docker image name
4056
shell: pwsh
4157
env:
@@ -52,22 +68,32 @@ jobs:
5268
5369
- name: Log in to GHCR
5470
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 }}
71+
shell: pwsh
72+
env:
73+
GHCR_USERNAME: ${{ github.actor }}
74+
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
run: |
76+
$env:GHCR_TOKEN | docker login ghcr.io --username $env:GHCR_USERNAME --password-stdin
77+
if ($LASTEXITCODE -ne 0) {
78+
Write-Error "Failed to log in to GHCR"
79+
exit 1
80+
}
6081
6182
- name: Pull cached image
6283
id: pull_cached
6384
continue-on-error: true
64-
timeout-minutes: 10
85+
timeout-minutes: 40
6586
shell: pwsh
6687
run: |
6788
$needBuild = $true
6889
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
90+
if ([string]::IsNullOrWhiteSpace($env:DOCKER_IMAGE) -or [string]::IsNullOrWhiteSpace($env:IMAGE_TAG)) {
91+
Write-Error "DOCKER_IMAGE or IMAGE_TAG is empty. DOCKER_IMAGE='$env:DOCKER_IMAGE' IMAGE_TAG='$env:IMAGE_TAG'"
92+
exit 1
93+
}
94+
95+
Write-Host "Attempting to pull hash-based tag: $($env:DOCKER_IMAGE):$($env:IMAGE_TAG)"
96+
$output = docker pull "$($env:DOCKER_IMAGE):$($env:IMAGE_TAG)" 2>&1
7197
$output | Out-Host
7298
7399
if ($LASTEXITCODE -eq 0) {
@@ -147,3 +173,11 @@ jobs:
147173
name: msvc-LastTest-log
148174
path: ${{ env.THRIFT_BUILD_DIR }}\Testing\Temporary\LastTest.log
149175
if-no-files-found: warn
176+
177+
- name: Remove Docker credential store
178+
if: always()
179+
shell: pwsh
180+
run: |
181+
if (-not [string]::IsNullOrWhiteSpace($env:DOCKER_CONFIG) -and (Test-Path $env:DOCKER_CONFIG)) {
182+
Remove-Item $env:DOCKER_CONFIG -Recurse -Force
183+
}

0 commit comments

Comments
 (0)