1- name : image-build
1+ name : Build and Test Docker Image
22
33on :
44 workflow_dispatch :
5+ inputs :
6+ run_tests :
7+ type : boolean
8+ description : " Test docker image after build"
9+ required : true
10+ default : true
11+ push :
12+ branches :
13+ - main
514
615env :
716 USER : ${{secrets.DOCKER_USER}}
1322 strategy :
1423 matrix :
1524 include :
16- - os : ubuntu-24.04
25+ - os : ${{vars.BASE_OS}}
1726 arch : amd64
18- - os : ubuntu-24.04 -arm
27+ - os : ${{vars.BASE_OS}} -arm
1928 arch : arm64
2029 steps :
2130 - name : Checkout
3241
3342 docker_manifest :
3443 needs : docker_build
35- runs-on : ubuntu-latest
44+ runs-on : ${{vars.BASE_OS}}-arm
3645 steps :
3746 - name : Log in to Docker Hub
3847 uses : docker/login-action@v3
@@ -45,23 +54,28 @@ jobs:
4554 docker manifest push ${{env.USER}}/${{env.IMAGE_NAME}}
4655
4756 docker_test :
57+ if : ${{github.event.inputs.run_tests == 'true' || github.event.inputs.run_tests == null}}
4858 needs : docker_manifest
4959 runs-on : ${{ matrix.os }}
5060 strategy :
5161 matrix :
5262 include :
53- - os : ubuntu-24.04
54- arch : amd64
55- - os : ubuntu-24.04 -arm
56- arch : arm64
63+ - os : ${{vars.BASE_OS}}
64+ platform : linux/ amd64
65+ - os : ${{vars.BASE_OS}} -arm
66+ platform : linux/ arm64
5767 steps :
5868 - name : Run Docker and check output
69+ shell : bash
5970 run : |
60- docker run -d --name ${{env.IMAGE_NAME}} --rm ${{env.USER}}/${{env.IMAGE_NAME}}:latest
61- sleep 5 # Wait for the container to start
62- output=$(docker exec ${{env.IMAGE_NAME}} wget -qO- localhost:8080)
63- if [[ "$output" != "Hello from image NODE:, POD:, CPU PLATFORM:linux/${{matrix.arch}}" ]]; then
64- echo "Unexpected output: $output"
65- exit 1
66- fi
67- echo "Expected output received: $output"
71+ # Run our container
72+ docker run -d --name ${{env.IMAGE_NAME}} --rm ${{env.USER}}/${{env.IMAGE_NAME}}:latest
73+ sleep 5 # Wait for the container to start
74+
75+ # Check the output
76+ output=$(docker exec ${{env.IMAGE_NAME}} wget -qO- localhost:8080)
77+ if [[ "$output" != "Hello from image NODE:, POD:, CPU PLATFORM:${{matrix.platform}}" ]]; then
78+ echo "Unexpected output: $output"
79+ exit 1
80+ fi
81+ echo "Expected output received: $output"
0 commit comments