Skip to content

Commit ba08bb3

Browse files
committed
fix: multi-arch docker images cannot be loaded on gh runners
1 parent 02ab955 commit ba08bb3

File tree

2 files changed

+49
-9
lines changed

2 files changed

+49
-9
lines changed

.github/workflows/pr.yml

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ on:
1313

1414
jobs:
1515
build:
16+
name: Build and Test
1617
runs-on: ubuntu-22.04
1718

1819
steps:
@@ -50,27 +51,66 @@ jobs:
5051
env:
5152
GITHUB_TOKEN: ${{ secrets.GH_TKN }}
5253

54+
docker_amd64:
55+
name: Build and Test for linux/amd64
56+
runs-on: ubuntu-22.04
57+
steps:
58+
- name: Clone repo
59+
uses: actions/checkout@v4
60+
with:
61+
fetch-depth: 0
62+
5363
# docs: https://github.com/marketplace/actions/build-and-push-docker-images
5464
- name: Set up QEMU
5565
uses: docker/setup-qemu-action@v3
66+
67+
- name: Set up Docker Buildx
68+
uses: docker/setup-buildx-action@v3
69+
70+
# docs: https://docs.docker.com/build/ci/github-actions/test-before-push/
71+
- name: Build Docker image for linux/amd64
72+
uses: docker/build-push-action@v6
5673
with:
57-
platforms: linux/amd64,linux/arm64
74+
push: false
75+
context: .
76+
file: Dockerfile
77+
platforms: linux/amd64
78+
load: true
79+
tags: ${{ github.repository }}:latest
80+
81+
- name: Run Docker tests for linux/amd64
82+
env:
83+
GITHUB_TOKEN: ${{ secrets.GH_TKN }}
84+
run: npm run docker:test
85+
86+
docker_arm64:
87+
name: Build and Test for linux/arm64
88+
runs-on: ubuntu-22.04
89+
steps:
90+
- name: Clone repo
91+
uses: actions/checkout@v4
92+
with:
93+
fetch-depth: 0
94+
95+
# docs: https://github.com/marketplace/actions/build-and-push-docker-images
96+
- name: Set up QEMU
97+
uses: docker/setup-qemu-action@v3
5898

5999
- name: Set up Docker Buildx
60100
uses: docker/setup-buildx-action@v3
61101

62102
# docs: https://docs.docker.com/build/ci/github-actions/test-before-push/
63-
- name: Build Docker image
103+
- name: Build Docker image for linux/arm64
64104
uses: docker/build-push-action@v6
65105
with:
66106
push: false
67107
context: .
68108
file: Dockerfile
69-
platforms: linux/amd64,linux/arm64
109+
platforms: linux/arm64
70110
load: true
71111
tags: ${{ github.repository }}:latest
72112

73-
- name: Run Docker tests
113+
- name: Run Docker tests for linux/arm64
74114
env:
75115
GITHUB_TOKEN: ${{ secrets.GH_TKN }}
76116
run: npm run docker:test

test.docker.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ docker run --rm \
99
-v ./dummy:/app/dummy \
1010
-w /app \
1111
-e DEBUG \
12-
github-commit-sign:latest "--help"
12+
docker.io/pirafrank/github-commit-sign:latest "--help"
1313

1414
echo "************** version *****************"
1515

@@ -18,7 +18,7 @@ docker run --rm \
1818
-v ./dummy:/app/dummy \
1919
-w /app \
2020
-e DEBUG \
21-
github-commit-sign:latest "-v"
21+
docker.io/pirafrank/github-commit-sign:latest "-v"
2222

2323
# commands below need GITHUB_TOKEN to be set.
2424
if [[ -f .env.sh ]]; then
@@ -39,7 +39,7 @@ docker run --rm \
3939
-w /app \
4040
-e GITHUB_TOKEN \
4141
-e DEBUG \
42-
github-commit-sign:latest commit -o pirafrank -r 'test-repo' -c dummy/file1.txt -m 'this is a commit msg'
42+
docker.io/pirafrank/github-commit-sign:latest commit -o pirafrank -r 'test-repo' -c dummy/file1.txt -m 'this is a commit msg'
4343

4444
echo "************** all separated *****************"
4545

@@ -49,7 +49,7 @@ docker run --rm \
4949
-w /app \
5050
-e GITHUB_TOKEN \
5151
-e DEBUG \
52-
github-commit-sign:latest commit -o pirafrank -r 'test-repo' -b main -c dummy/file1.txt -m onewordcommitmsg
52+
docker.io/pirafrank/github-commit-sign:latest commit -o pirafrank -r 'test-repo' -b main -c dummy/file1.txt -m onewordcommitmsg
5353

5454
echo "************** all as one arg *****************"
5555

@@ -61,4 +61,4 @@ docker run --rm \
6161
-w /app \
6262
-e GITHUB_TOKEN \
6363
-e DEBUG \
64-
github-commit-sign:latest "commit -o pirafrank -r "test-repo" -b main -c dummy/file1.txt -m 'this is a commit msg'"
64+
docker.io/pirafrank/github-commit-sign:latest "commit -o pirafrank -r "test-repo" -b main -c dummy/file1.txt -m 'this is a commit msg'"

0 commit comments

Comments
 (0)