Skip to content

Commit

Permalink
Enhance Docker image handling in GitHub Actions workflow: added suppo…
Browse files Browse the repository at this point in the history
…rt for multi-architecture images using Docker Buildx, updated image pull and push steps, and improved success message to include supported architectures.
  • Loading branch information
lltx committed Dec 19, 2024
1 parent 502d850 commit 5a1a2d9
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions .github/workflows/mirror.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,24 @@ jobs:
env:
QYWX_ROBOT_URL: ${{ secrets.QYWX_ROBOT_URL }}
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Registry
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} ${{ github.event.inputs.TARGET_REGISTRY }}

- name: Pull, tag, and push Docker image
- name: Pull and push all platform images
run: |
docker pull ${{ github.event.inputs.IMAGE_NAME }}:${{ github.event.inputs.IMAGE_VERSION }}
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 }}
docker push ${{ github.event.inputs.TARGET_REGISTRY }}/${{ github.event.inputs.TARGET_REPOSITORY }}/${{ github.event.inputs.NEW_NAME }}:${{ github.event.inputs.IMAGE_VERSION }}
# 创建一个新的 builder 实例
docker buildx create --use
# 拉取源镜像的 manifest list
docker buildx imagetools inspect ${{ github.event.inputs.IMAGE_NAME }}:${{ github.event.inputs.IMAGE_VERSION }}
# 使用 buildx 拉取并推送所有架构的镜像
docker buildx imagetools create \
--tag ${{ github.event.inputs.TARGET_REGISTRY }}/${{ github.event.inputs.TARGET_REPOSITORY }}/${{ github.event.inputs.NEW_NAME }}:${{ github.event.inputs.IMAGE_VERSION }} \
${{ github.event.inputs.IMAGE_NAME }}:${{ github.event.inputs.IMAGE_VERSION }}
- name: qyweixin send message
if: ${{ env.QYWX_ROBOT_URL != '' }}
Expand All @@ -48,7 +58,10 @@ jobs:
with:
msgtype: markdown
content: |
# 镜像同步成功
# 镜像同步成功(多架构)
```
${{ env.IMAGE_URL }}
支持的架构:
$(docker buildx imagetools inspect ${{ env.IMAGE_URL }} | grep -A 5 "Platform:")
```

0 comments on commit 5a1a2d9

Please sign in to comment.