Skip to content

Commit 5a1a2d9

Browse files
committed
Enhance Docker image handling in GitHub Actions workflow: added support for multi-architecture images using Docker Buildx, updated image pull and push steps, and improved success message to include supported architectures.
1 parent 502d850 commit 5a1a2d9

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

.github/workflows/mirror.yaml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,24 @@ jobs:
3030
env:
3131
QYWX_ROBOT_URL: ${{ secrets.QYWX_ROBOT_URL }}
3232
steps:
33+
- name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v3
35+
3336
- name: Login to Docker Registry
3437
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} ${{ github.event.inputs.TARGET_REGISTRY }}
3538

36-
- name: Pull, tag, and push Docker image
39+
- name: Pull and push all platform images
3740
run: |
38-
docker pull ${{ github.event.inputs.IMAGE_NAME }}:${{ github.event.inputs.IMAGE_VERSION }}
39-
docker tag ${{ github.event.inputs.IMAGE_NAME }}:${{ github.event.inputs.IMAGE_VERSION }} ${{ github.event.inputs.TARGET_REGISTRY }}/${{ github.event.inputs.TARGET_REPOSITORY }}/${{ github.event.inputs.NEW_NAME }}:${{ github.event.inputs.IMAGE_VERSION }}
40-
docker push ${{ github.event.inputs.TARGET_REGISTRY }}/${{ github.event.inputs.TARGET_REPOSITORY }}/${{ github.event.inputs.NEW_NAME }}:${{ github.event.inputs.IMAGE_VERSION }}
41+
# 创建一个新的 builder 实例
42+
docker buildx create --use
43+
44+
# 拉取源镜像的 manifest list
45+
docker buildx imagetools inspect ${{ github.event.inputs.IMAGE_NAME }}:${{ github.event.inputs.IMAGE_VERSION }}
46+
47+
# 使用 buildx 拉取并推送所有架构的镜像
48+
docker buildx imagetools create \
49+
--tag ${{ github.event.inputs.TARGET_REGISTRY }}/${{ github.event.inputs.TARGET_REPOSITORY }}/${{ github.event.inputs.NEW_NAME }}:${{ github.event.inputs.IMAGE_VERSION }} \
50+
${{ github.event.inputs.IMAGE_NAME }}:${{ github.event.inputs.IMAGE_VERSION }}
4151
4252
- name: qyweixin send message
4353
if: ${{ env.QYWX_ROBOT_URL != '' }}
@@ -48,7 +58,10 @@ jobs:
4858
with:
4959
msgtype: markdown
5060
content: |
51-
# 镜像同步成功
61+
# 镜像同步成功(多架构)
5262
```
5363
${{ env.IMAGE_URL }}
64+
65+
支持的架构:
66+
$(docker buildx imagetools inspect ${{ env.IMAGE_URL }} | grep -A 5 "Platform:")
5467
```

0 commit comments

Comments
 (0)