@@ -2,46 +2,48 @@ name: CI
22
33on :
44 push :
5- branches : [ "main" ]
5+ branches :
6+ - main
67 pull_request :
7- branches : [ "main" ]
8-
9- env :
10- IMAGE_NAME : ${{ github.event.repository.name }}
118
129jobs :
13- build-and-push-image :
10+ build_and_test :
1411 runs-on : ubuntu-latest
12+ if : ${{ github.repository == 'codewars/riscv' }}
1513 permissions :
1614 contents : read
1715 packages : write
1816 steps :
1917 - uses : actions/checkout@v3
2018
21- - name : Enable QEMU user-mode emulation
22- run : sudo apt-get update && sudo apt-get install -y qemu-user-static
19+ - name : Set up QEMU
20+ uses : docker/setup-qemu-action@v2
21+ with :
22+ platforms : riscv64
23+
24+ - name : Set up Docker Buildx
25+ uses : docker/setup-buildx-action@v2
2326
2427 - name : Build image
25- run : docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" --platform linux/riscv64
28+ uses : docker/build-push-action@v3
29+ with :
30+ context : .
31+ push : false
32+ # Make the image available in next step
33+ load : true
34+ platforms : linux/riscv64
35+ tags : ghcr.io/codewars/riscv:latest
36+ cache-from : type=gha
37+ cache-to : type=gha,mode=max
2638
2739 - name : Run multiply example
28- run : IMAGE_TAG=$IMAGE_NAME bin/run multiply
40+ run : bin/run multiply
2941
3042 - name : Run multiply-failing example
31- run : IMAGE_TAG=$IMAGE_NAME bin/run multiply-failing
43+ run : bin/run multiply-failing
3244
3345 - name : Run syntax-error example
34- run : IMAGE_TAG=$IMAGE_NAME bin/run syntax-error || true
46+ run : bin/run syntax-error || true
3547
3648 - name : Run invalid-regname example
37- run : IMAGE_TAG=$IMAGE_NAME bin/run invalid-regname || true
38-
39- - name : Log in to registry
40- run : echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
41-
42- - name : Push image
43- run : |
44- IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
45- IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
46- docker tag $IMAGE_NAME $IMAGE_ID:latest
47- docker push $IMAGE_ID:latest
49+ run : bin/run invalid-regname || true
0 commit comments