diff --git a/.github/workflows/docker-pull.yml b/.github/workflows/docker-pull.yml index f249f4e..7b3aa85 100644 --- a/.github/workflows/docker-pull.yml +++ b/.github/workflows/docker-pull.yml @@ -3,22 +3,18 @@ name: 拉取镜像推送 on: workflow_dispatch: inputs: - IMAGE_NAME: - description: '原镜像名称:版本' + IMAGES_FILE: + description: '镜像列表文件路径' required: true - default: 'mysql/mysql-server' - NEW_NAME: - description: '同步后镜像名称:版本' - required: true - default: 'mysql-server' + default: 'images.txt' TARGET_REGISTRY: description: '仓库地址' required: true - default: 'registry.cn-chengdu.aliyuncs.com' + default: 'registry.cn-guangzhou.aliyuncs.com' TARGET_REPOSITORY: description: '空间名称' required: true - default: 'aopkcn' + default: 'kubesphere_wen' ARCH: description: '系统架构' required: true @@ -29,7 +25,7 @@ on: - arm64 - arm/v7 - arm/v6 - - 386 + - "386" - s390x - ppc64le @@ -37,6 +33,16 @@ jobs: build: runs-on: ubuntu-latest steps: + - name: 检出代码库 + uses: actions/checkout@v2 + + - name: 读取镜像列表文件 + id: read_images + run: | + images=$(cat ${{ github.event.inputs.IMAGES_FILE }} | tr '\n' ' ') + echo "Images: $images" + echo "images=$images" >> $GITHUB_ENV + - name: 登录到 Docker 仓库 id: login run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} ${{ github.event.inputs.TARGET_REGISTRY }} @@ -53,9 +59,19 @@ jobs: - name: 拉取、标记并推送 Docker 镜像 id: pull_tag_push run: | - docker pull --platform ${{ github.event.inputs.ARCH }} ${{ github.event.inputs.IMAGE_NAME }} - docker tag ${{ github.event.inputs.IMAGE_NAME }} ${{ github.event.inputs.TARGET_REGISTRY }}/${{ github.event.inputs.TARGET_REPOSITORY }}/${{ github.event.inputs.NEW_NAME }} - docker push ${{ github.event.inputs.TARGET_REGISTRY }}/${{ github.event.inputs.TARGET_REPOSITORY }}/${{ github.event.inputs.NEW_NAME }} + for image in ${{ env.images }}; do + + original_image=$(echo $image | cut -d':' -f1) + tag=$(echo $image | cut -d':' -f2) + + base_image=$(basename $original_image) + + new_image="${{ github.event.inputs.TARGET_REGISTRY }}/${{ github.event.inputs.TARGET_REPOSITORY }}/$base_image:$tag" + + docker pull --platform ${{ github.event.inputs.ARCH }} $original_image:$tag + docker tag $original_image:$tag $new_image + docker push $new_image + done continue-on-error: true - name: 检查镜像推送成功 @@ -64,4 +80,4 @@ jobs: - name: 检查镜像推送失败 if: ${{ steps.pull_tag_push.outcome != 'success' }} - run: echo "Docker 镜像推送失败" + run: echo "Docker 镜像推送失败" \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..40ffbe0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.idea +.vscode/ +nohup.out + diff --git a/images.txt b/images.txt new file mode 100644 index 0000000..e26a2a0 --- /dev/null +++ b/images.txt @@ -0,0 +1,4 @@ +jumpserver/chen:v4.0.2-ce +jumpserver/koko:v4.0.2-ce +jumpserver/lion:v4.0.2-ce +jumpserver/web:v4.0.2-ce