Skip to content

Commit 5af2b1d

Browse files
committed
Additional Variables
1 parent b27a929 commit 5af2b1d

File tree

2 files changed

+35
-17
lines changed

2 files changed

+35
-17
lines changed

.github/workflows/image-build.yml

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
name: image-build
1+
name: Build and Test Docker Image
22

33
on:
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

615
env:
716
USER: ${{secrets.DOCKER_USER}}
@@ -13,9 +22,9 @@ jobs:
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
@@ -32,7 +41,7 @@ jobs:
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"

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
- Click **Generate** and copy the token.
2828
**Note**: Make sure to save the token securely as it will not be shown again.
2929

30-
### Add Docker Credentials to GitHub Actions
30+
### Add Variables to GitHub Actions
3131

3232
1. Go to your GitHub repository.
3333
2. Click on the **Settings** tab.
@@ -36,6 +36,10 @@
3636
5. Add the following secrets:
3737
- `DOCKER_USER`: Your Docker username.
3838
- `DOCKER_PAT`: Your Docker Personal Access Token we generated above.
39+
6. Move from the **Secrets** tab to the **Variables** tab
40+
7. Click the **New repository variable** button.
41+
8. Add the following variable:
42+
- `BASE_OS`: `ubuntu-24.04`
3943

4044
### Run the GitHub Actions Workflow
4145

0 commit comments

Comments
 (0)