Skip to content

Commit c1f8f8c

Browse files
committed
test: docker manifest 3
1 parent 77477a3 commit c1f8f8c

File tree

1 file changed

+64
-18
lines changed

1 file changed

+64
-18
lines changed

.github/workflows/docker-image.yml

Lines changed: 64 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Docker Image CI Test
1+
name: Docker Image CI
22

33
on:
44
workflow_dispatch: # 允许手动触发工作流
@@ -62,31 +62,76 @@ jobs:
6262
# docker manifest create ghcr.io/lightislost/python:3.9-slim-bookworm ghcr.io/lightislost/python:3.9-slim-bookworm-arm64 ghcr.io/lightislost/python:3.9-slim-bookworm-amd64
6363
# docker manifest inspect ghcr.io/lightislost/python:3.9-slim-bookworm
6464

65-
- name: Build and push adm64
66-
uses: docker/build-push-action@v2
67-
with:
68-
context: ${{ matrix.image.context }}
69-
file: ${{ matrix.image.dockerfile }}
70-
push: true
71-
tags: ${{ matrix.image.tag }}-amd64
72-
platforms: linux/amd64
65+
# - name: Build and push adm64
66+
# uses: docker/build-push-action@v2
67+
# with:
68+
# context: ${{ matrix.image.context }}
69+
# file: ${{ matrix.image.dockerfile }}
70+
# push: true
71+
# tags: ${{ matrix.image.tag }}-amd64
72+
# platforms: linux/amd64
73+
74+
- name: Build and push with retry for amd64
75+
run: |
76+
max_retries=3
77+
count=0
78+
success=false
7379
80+
while [[ $count -lt $max_retries ]]; do
81+
echo "Attempt $(($count + 1)) of $max_retries..."
82+
docker buildx build --push \
83+
--platform linux/amd64 \
84+
--tag ${{ matrix.image.tag }}-amd64 \
85+
-f ${{ matrix.image.dockerfile }} ${{ matrix.image.context }} && success=true && break
86+
87+
count=$(($count + 1))
88+
echo "Build failed, retrying in 5 seconds..."
89+
sleep 5
90+
done
91+
92+
if [ "$success" = false ]; then
93+
echo "Build failed after $max_retries attempts."
94+
exit 1
95+
fi
96+
3
7497
- name: docker image
7598
run: |
7699
docker images
77100
docker rmi ${{ matrix.image.tag }}-amd64
78101
docker images
79102
103+
# - name: Build and push amr64
104+
# uses: docker/build-push-action@v2
105+
# with:
106+
# context: ${{ matrix.image.context }}
107+
# file: ${{ matrix.image.dockerfile }}
108+
# push: true
109+
# tags: ${{ matrix.image.tag }}-arm64
110+
# platforms: linux/arm64
111+
112+
- name: Build and push with retry for arm64
113+
run: |
114+
max_retries=3
115+
count=0
116+
success=false
117+
118+
while [[ $count -lt $max_retries ]]; do
119+
echo "Attempt $(($count + 1)) of $max_retries..."
120+
docker buildx build --push \
121+
--platform linux/arm64 \
122+
--tag ${{ matrix.image.tag }}-arm64 \
123+
-f ${{ matrix.image.dockerfile }} ${{ matrix.image.context }} && success=true && break
124+
125+
count=$(($count + 1))
126+
echo "Build failed, retrying in 5 seconds..."
127+
sleep 5
128+
done
129+
130+
if [ "$success" = false ]; then
131+
echo "Build failed after $max_retries attempts."
132+
exit 1
133+
fi
80134
81-
- name: Build and push amr64
82-
uses: docker/build-push-action@v2
83-
with:
84-
context: ${{ matrix.image.context }}
85-
file: ${{ matrix.image.dockerfile }}
86-
push: true
87-
tags: ${{ matrix.image.tag }}-arm64
88-
platforms: linux/arm64
89-
90135
- name: docker image
91136
run: |
92137
docker images
@@ -98,6 +143,7 @@ jobs:
98143
docker images
99144
docker manifest create ${{ matrix.image.tag }} ${{ matrix.image.tag }}-arm64 ${{ matrix.image.tag }}-amd64
100145
docker manifest inspect ${{ matrix.image.tag }}
146+
docker manifest push ${{ matrix.image.tag }}
101147
102148
- name: Check disk space
103149
run: df -h

0 commit comments

Comments
 (0)