1
- name : image-build
1
+ name : Build and Test Docker Image
2
2
3
3
on :
4
4
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
5
14
6
15
env :
7
16
USER : ${{secrets.DOCKER_USER}}
13
22
strategy :
14
23
matrix :
15
24
include :
16
- - os : ubuntu-24.04
25
+ - os : ${{vars.BASE_OS}}
17
26
arch : amd64
18
- - os : ubuntu-24.04 -arm
27
+ - os : ${{vars.BASE_OS}} -arm
19
28
arch : arm64
20
29
steps :
21
30
- name : Checkout
32
41
33
42
docker_manifest :
34
43
needs : docker_build
35
- runs-on : ubuntu-latest
44
+ runs-on : ${{vars.BASE_OS}}-arm
36
45
steps :
37
46
- name : Log in to Docker Hub
38
47
uses : docker/login-action@v3
@@ -45,23 +54,28 @@ jobs:
45
54
docker manifest push ${{env.USER}}/${{env.IMAGE_NAME}}
46
55
47
56
docker_test :
57
+ if : ${{github.event.inputs.run_tests == 'true' || github.event.inputs.run_tests == null}}
48
58
needs : docker_manifest
49
59
runs-on : ${{ matrix.os }}
50
60
strategy :
51
61
matrix :
52
62
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
57
67
steps :
58
68
- name : Run Docker and check output
69
+ shell : bash
59
70
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