From 803eee00fb54a91b506cdb36ee64acf78ee3d358 Mon Sep 17 00:00:00 2001 From: Chris Granade Date: Wed, 8 Jan 2020 08:59:38 -0800 Subject: [PATCH] Delay updating binder until MCR image is available. (#287) * Delay updating binder until MCR image is available. * Print out diagnostics on spinlock. * Remove trigger used in tests. --- .github/workflows/main.yml | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2688a675fb1e..27a7dd42389c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,7 +23,7 @@ jobs: $Now = [DateTime]::Now; $ImageTag = "${{ github.sha }}" $RepoName = "public/quantum/samples" - + $LocalTag = "${RepoName}:${ImageTag}" $RemoteRepo = "${{ secrets.ACR_REGISTRY }}/${RepoName}" @@ -33,6 +33,30 @@ jobs: docker tag $LocalTag "${RemoteRepo}:latest" docker push "${RemoteRepo}:latest" shell: pwsh + - name: Wait for image to publish + run: | + function Get-Tags() { + Invoke-WebRequest https://mcr.microsoft.com/v2/quantum/samples/tags/list ` + | Select-Object -ExpandProperty Content ` + | ConvertFrom-Json ` + | Select-Object -ExpandProperty tags ` + | Write-Output; + } + + $ImageAvailable = $false; + $ImageTag = "${{ github.sha }}"; + $CheckInterval = 30; # [seconds] + while (-not $ImageAvailable) { + if ($ImageTag -in (Get-Tags)) { + Write-Host "##[info] Image $ImageTag now available on mcr.microsoft.com, proceeding." + $ImageAvailable = $true; + } else { + Write-Host "##[info] Image $ImageTag not yet available on mcr.microsoft.com, waiting $CheckInterval seconds."; + } + + Start-Sleep -Seconds $CheckInterval; + } + shell: pwsh - name: Update Binder configuration run: | git config --local user.email "action@github.com" @@ -40,7 +64,7 @@ jobs: $ThisCommit = "${{ github.sha }}" git checkout ⭐binder git reset --hard $ThisCommit - + $Dockerfile = Get-Content ./Dockerfile; $Dockerfile ` | ForEach-Object { @@ -55,7 +79,7 @@ jobs: git add Dockerfile git commit -m "Updated Binder to use $ThisCommit." shell: pwsh - + - name: Push changes uses: ad-m/github-push-action@master with: