Skip to content

Commit 47276de

Browse files
committed
ci: test --version after build
1 parent f1438fb commit 47276de

File tree

3 files changed

+54
-8
lines changed

3 files changed

+54
-8
lines changed

.github/actions/docker-build/action.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
# Action that wraps together all the necessary actions to build an image and publish it.
22
# It does not include login actions.
33
# This is a convenience, so that we know that everything related to the build lies in this file,
4-
# and if it gets updated we can automatically run our `test-docker-build` from `build-test.yml.`
4+
# and if it gets updated we can automatically run our `test-docker-build` from `build-test.yml.`,
5+
# so there is no confusion about which is the job that was updated, if there are many in the same workflow file.
56

67
name: "Docker Build"
78
description: "Builds Docker images with optional caching and multi-platform support"
89

910
inputs:
10-
push-image:
11+
push:
1112
description: "Whether to push the built image"
1213
required: false
1314
default: "false"
15+
load:
16+
description: "Whether to load the built image"
17+
required: false
18+
default: "false"
1419
platforms:
1520
description: "Target platforms for the build"
1621
required: false
@@ -55,9 +60,10 @@ runs:
5560
with:
5661
context: ${{ inputs.context }}
5762
file: ${{ inputs.dockerfile }}
58-
push: ${{ inputs['push-image'] }}
63+
push: ${{ inputs.push }}
5964
platforms: ${{ inputs.platforms }}
6065
tags: ${{ steps.meta.outputs.tags }}
6166
labels: ${{ steps.meta.outputs.labels }}
6267
cache-from: ${{ inputs['cache-from'] }}
6368
cache-to: ${{ inputs['cache-to'] }}
69+
load: ${{ inputs.load }}

.github/workflows/build-test.yml

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ jobs:
7171
docker: ${{ steps.docker-changes.outputs.docker }}
7272
workflow: ${{ steps.docker-changes.outputs.workflow }}
7373

74-
test-docker-build:
74+
test-docker-build-arm64:
7575
needs: [should-test-docker-build]
76-
name: Test Docker build
76+
name: Test Docker build ARM64
7777
runs-on: ubuntu-latest
7878
if: (needs.should-test-docker-build.outputs.workflow == 'true' || needs.should-test-docker-build.outputs.docker == 'true') && !startsWith(github.event.head_commit.message, 'bump:')
7979
permissions:
@@ -96,6 +96,46 @@ jobs:
9696
context: .
9797
file: ./Dockerfile
9898
push: false
99-
platforms: linux/amd64,linux/arm64
99+
load: true
100+
platforms: linux/arm64
100101
cache-from: type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache
101-
102+
image-name: build-arm64
103+
104+
- name: Test
105+
run: |
106+
docker run --rm build-arm64 --version
107+
108+
test-docker-build-amd64:
109+
needs: [should-test-docker-build]
110+
name: Test Docker build AMD64
111+
runs-on: ubuntu-latest
112+
if: (needs.should-test-docker-build.outputs.workflow == 'true' || needs.should-test-docker-build.outputs.docker == 'true') && !startsWith(github.event.head_commit.message, 'bump:')
113+
permissions:
114+
contents: read
115+
packages: read
116+
steps:
117+
- name: Check out the repo
118+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
119+
120+
- name: Log in to GitHub Container Registry
121+
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
122+
with:
123+
registry: ghcr.io
124+
username: ${{ github.actor }}
125+
password: ${{ secrets.GITHUB_TOKEN }}
126+
127+
- name: Build image
128+
uses: ./.github/actions/docker-build
129+
with:
130+
context: .
131+
file: ./Dockerfile
132+
push: false
133+
load: true
134+
platforms: linux/amd64
135+
cache-from: type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache
136+
image-name: build-amd64
137+
138+
- name: Test
139+
run: |
140+
docker images
141+
docker run --rm build-amd64 --version

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
- name: Build and push Docker image
5454
uses: ./.github/actions/docker-build
5555
with:
56-
push-image: "true"
56+
push: "true"
5757
platforms: linux/amd64,linux/arm64
5858
dockerfile: ./Dockerfile
5959
context: .

0 commit comments

Comments
 (0)