Docker Image Sync #52
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Image Sync | |
on: | |
workflow_dispatch: | |
inputs: | |
IMAGE_NAME: | |
description: '原镜像名称' | |
required: true | |
default: 'nacos/nacos-server' | |
NEW_NAME: | |
description: '同步后镜像名称' # 只能写单名,否则就会被识别为命名空间,可能导致失败 | |
required: true | |
default: 'nacos-server' | |
IMAGE_VERSION: | |
description: '镜像版本' | |
required: true | |
default: 'v2.4.3' | |
TARGET_REGISTRY: | |
description: '仓库地址' | |
required: true | |
default: 'registry.cn-shanghai.aliyuncs.com' | |
TARGET_REPOSITORY: | |
description: '空间名称' | |
required: true | |
default: 'github-docker-sync' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
QYWX_ROBOT_URL: ${{ secrets.QYWX_ROBOT_URL }} | |
steps: | |
- 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 | |
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 }} |