From 9788671b1a52792b00a2dd96943e998dbf8998f9 Mon Sep 17 00:00:00 2001 From: Yifan Gao Date: Wed, 24 Jan 2024 00:53:04 +0800 Subject: [PATCH] Update Github Action --- .github/workflows/trigger-build.yml | 4 ++-- check-and-build.ps1 | 25 ++++++++++++++----------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/trigger-build.yml b/.github/workflows/trigger-build.yml index 1872f6d..cbf17b9 100644 --- a/.github/workflows/trigger-build.yml +++ b/.github/workflows/trigger-build.yml @@ -7,7 +7,7 @@ on: jobs: trigger: - runs-on: windows-2019 + runs-on: windows-2022 strategy: matrix: @@ -19,7 +19,7 @@ jobs: with: ref: ${{ github.ref }} - name: Check if image is up-to-date, and build if not - run: .\check-and-build.ps1 $env:TRAIN $env:USERNAME $env:PASSWORD + run: .\check-and-build.ps1 $env:TRAIN ${{ github.actor }} ${{ secrets.GITHUB_TOKEN }} env: TRAIN: ${{ matrix.train }} USERNAME: ${{ secrets.DOCKER_USERNAME }} diff --git a/check-and-build.ps1 b/check-and-build.ps1 index 6df4e04..351ff47 100644 --- a/check-and-build.ps1 +++ b/check-and-build.ps1 @@ -28,12 +28,20 @@ $latestToolchainVer = ( ` ).split('"')[2].trim() echo "--> Latest toolchain version: rustc $latestToolchainVer" -docker pull yodal/rust-windows:${train} +echo "--> Logging into Docker registry $registry" +if($username -and $password) { + docker login -u $username -p $password ghcr.io + if($LASTEXITCODE) { + exit $LASTEXITCODE + } +} + +docker pull ghcr.io/automesh-network/rust-windows:${train} if($LASTEXITCODE) { exit $LASTEXITCODE } $currentImageVer = ( ` - (docker run --rm yodal/rust-windows:${train} rustc -V) ` + (docker run --rm ghcr.io/automesh-network/rust-windows:${train} rustc -V) ` | Select-String -Pattern "rustc" ` | Select-Object -Expand Line ` ).trim() @@ -45,28 +53,23 @@ echo "--> Current image toolchain version: $currentImageVer" if("rustc $latestToolchainVer" -ne "$currentImageVer") { echo "--> Image is out-of-date, rebuilding iamge" - docker build -t yodal/rust-windows:${train} -f .\${train}\Dockerfile . + docker build -t ghcr.io/automesh-network/rust-windows:${train} -f .\${train}\Dockerfile . if($LASTEXITCODE) { exit $LASTEXITCODE } if($username -and $password) { - docker login -u $username -p $password - if($LASTEXITCODE) { - exit $LASTEXITCODE - } - - docker push yodal/rust-windows:${train} + docker push ghcr.io/automesh-network/rust-windows:${train} if($LASTEXITCODE) { exit $LASTEXITCODE } if($train -eq "stable") { - docker tag yodal/rust-windows:stable yodal/rust-windows:latest + docker tag ghcr.io/automesh-network/rust-windows:stable ghcr.io/automesh-network/rust-windows:latest if($LASTEXITCODE) { exit $LASTEXITCODE } - docker push yodal/rust-windows:latest + docker push ghcr.io/automesh-network/rust-windows:latest if($LASTEXITCODE) { exit $LASTEXITCODE }