Skip to content

Commit 9109197

Browse files
authored
Update build-nabla.yml, add CE_IMAGE_UPDATE_TOKEN secret, use an endpoint to update production image
instead of key
1 parent 0d4d7f9 commit 9109197

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

.github/workflows/build-nabla.yml

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -312,17 +312,36 @@ jobs:
312312
commit_message: "[CI] badges update"
313313

314314
deploy-production:
315-
name: Deploy to production host
315+
name: Deploy Godbolt production image
316316
if: ${{ always() && github.ref == 'refs/heads/master' }}
317317
needs: build-windows
318-
runs-on: ubuntu-latest
318+
runs-on: windows-2022
319319

320320
steps:
321-
- name: Pull latest images, re-run containers
322-
uses: appleboy/ssh-action@v1
323-
with:
324-
host: ${{ secrets.CE_HOST }}
325-
username: ${{ secrets.CE_USER }}
326-
key: ${{ secrets.CE_KEY }}
327-
script: |
328-
powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -NoExit -File C:\Scripts\startup-docker.ps1
321+
- name: Invoke Web Request
322+
run: |
323+
function Invoke-UpdateImages {
324+
param(
325+
[string]$Token,
326+
[string]$Url = 'https://godbolt.devsh.eu/api/update-images'
327+
)
328+
329+
$resp = Invoke-WebRequest -Method Post `
330+
-Uri $Url `
331+
-Headers @{ 'X-API-Token' = $Token } `
332+
-SkipHttpErrorCheck
333+
334+
$httpCode = $resp.StatusCode
335+
$body = $resp.Content | ConvertFrom-Json
336+
337+
Write-Host "HTTP code : $httpCode"
338+
Write-Host "status : $($body.status)"
339+
Write-Host "message : $($body.message)"
340+
341+
if ($httpCode -ne 200) {
342+
throw "Request failed"
343+
}
344+
}
345+
346+
$token = '${{ secrets.CE_IMAGE_UPDATE_TOKEN }}'
347+
Invoke-UpdateImages -Token $token

0 commit comments

Comments
 (0)