Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v1 #2

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 30 additions & 14 deletions .github/workflows/docker-pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,14 +25,24 @@ on:
- arm64
- arm/v7
- arm/v6
- 386
- "386"
- s390x
- ppc64le

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 }}
Expand All @@ -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: 检查镜像推送成功
Expand All @@ -64,4 +80,4 @@ jobs:

- name: 检查镜像推送失败
if: ${{ steps.pull_tag_push.outcome != 'success' }}
run: echo "Docker 镜像推送失败"
run: echo "Docker 镜像推送失败"
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.idea
.vscode/
nohup.out

4 changes: 4 additions & 0 deletions images.txt
Original file line number Diff line number Diff line change
@@ -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