Skip to content

Commit

Permalink
Update Github Action
Browse files Browse the repository at this point in the history
  • Loading branch information
gaoyifan committed Jan 23, 2024
1 parent 9f52111 commit 9788671
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/trigger-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
trigger:
runs-on: windows-2019
runs-on: windows-2022

strategy:
matrix:
Expand All @@ -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 }}
Expand Down
25 changes: 14 additions & 11 deletions check-and-build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
}
Expand Down

0 comments on commit 9788671

Please sign in to comment.