Skip to content

PIG 镜像 action

PIG 镜像 action #76

Workflow file for this run

name: PIG 镜像 action
on:
workflow_dispatch:
inputs:
IMAGE_NAME:
description: '原镜像名称'
required: true
default: 'mysql/mysql-server'
NEW_NAME:
description: '同步后镜像名称'
required: true
default: 'mysql-server'
IMAGE_VERSION:
description: '镜像版本'
required: true
default: 'latest'
TARGET_REGISTRY:
description: '仓库地址'
required: true
default: 'registry.cn-hangzhou.aliyuncs.com'
TARGET_REPOSITORY:
description: '空间名称'
required: true
default: 'dockerhub_mirror'
jobs:
build:
runs-on: ubuntu-latest
env:
QYWX_ROBOT_URL: ${{ secrets.QYWX_ROBOT_URL }}
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Registry
uses: docker/login-action@v3
with:
registry: ${{ github.event.inputs.TARGET_REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Pull and push all platform images
run: |
# 创建一个新的 builder 实例
docker buildx create --use --name multiarch-builder
# 显示源镜像信息
echo "源镜像支持的架构:"
docker buildx imagetools inspect ${{ github.event.inputs.IMAGE_NAME }}:${{ github.event.inputs.IMAGE_VERSION }}
# 使用 buildx 构建并推送多架构镜像
docker buildx build \
--platform linux/amd64,linux/arm64 \
--pull \
--build-arg SOURCE_IMAGE=${{ github.event.inputs.IMAGE_NAME }}:${{ github.event.inputs.IMAGE_VERSION }} \
--tag ${{ github.event.inputs.TARGET_REGISTRY }}/${{ github.event.inputs.TARGET_REPOSITORY }}/${{ github.event.inputs.NEW_NAME }}:${{ github.event.inputs.IMAGE_VERSION }} \
--push \
- <<EOF
FROM --platform=\${TARGETPLATFORM} ${SOURCE_IMAGE}
EOF
- name: qyweixin send message
if: ${{ env.QYWX_ROBOT_URL != '' }}
uses: chf007/action-wechat-work@master
env:
WECHAT_WORK_BOT_WEBHOOK: ${{secrets.QYWX_ROBOT_URL}}
IMAGE_URL: ${{ github.event.inputs.TARGET_REGISTRY }}/${{ github.event.inputs.TARGET_REPOSITORY }}/${{ github.event.inputs.NEW_NAME }}:${{ github.event.inputs.IMAGE_VERSION }}
with:
msgtype: markdown
content: |
# 镜像同步成功(多架构)
```
镜像地址:${{ env.IMAGE_URL }}
支持的架构:
${{ toJSON(steps.build.outputs.platforms) }}
```