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

Support Pull and Push #14

Open
wants to merge 5 commits into
base: master
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
39 changes: 39 additions & 0 deletions .github/workflows/amd64-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: x86-64 Pull and Push Docker Image
on:
workflow_dispatch:
inputs:
docker_images:
description: 'docker image names, comma separated'
required: true
default: 'alpine:latest' # default Docker image
jobs:
pull_and_push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
#- name: Clean up Docker to free space
# run: |
# docker system prune -a -f
# docker volume prune -f
- name: Log in to target registry
env:
TARGET_REGISTRY: ${{ secrets.TARGET_REGISTRY }}
TARGET_REGISTRY_USERNAME: ${{ secrets.TARGET_REGISTRY_USERNAME }}
TARGET_REGISTRY_PASSWORD: ${{ secrets.TARGET_REGISTRY_PASSWORD }}
run: |
REGISTRY_HOST=$(echo "$TARGET_REGISTRY" | awk -F/ '{print $1}')
echo "$TARGET_REGISTRY_PASSWORD" | docker login "$REGISTRY_HOST" -u "$TARGET_REGISTRY_USERNAME" --password-stdin
- name: Pull docker images and push
env:
TARGET_REGISTRY: ${{ secrets.TARGET_REGISTRY }}
run: |
images="${{ github.event.inputs.docker_images }}"
IFS=',' read -r -a image_array <<< "$images"
for image in "${image_array[@]}"; do
image_name=$(basename "$image")
new_image="${TARGET_REGISTRY}${image_name}"
docker pull "${image}" --platform "linux/amd64"
docker tag "${image}" "${new_image}"
docker push "${new_image}"
done
31 changes: 20 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,24 @@
它是一个工作流。可快速构建指定架构/平台的docker镜像

## 使用说明
### 用法一:pull镜像打成tar包下载
https://wkdaily.cpolar.cn/archives/gc
## 教学视频
https://www.bilibili.com/video/BV1EZ421M7mL
## 解压工具
> Windows 上推荐使用7zip<br>
> macOS 推荐使用MacZip<br>
> Linux上推荐直接用tar 命令

## 相关项目
https://github.com/wukongdaily/OrangePiShell
## 在哪里可以搜索或查询docker镜像的详细信息
### [查询镜像的详细信息 点击这里直达](https://docker.fxxk.dedyn.io/)
### 用法二:pull镜像并push到自己的仓库
首先在settings/secrets/actions中设置如下的Repository secrets:

TARGET_REGISTRY: 自己的镜像仓库地址,例如registry.cn-hangzhou.aliyuncs.com/yourname/
TARGET_REGISTRY_PASSWORD: 镜像仓库用户名
TARGET_REGISTRY_USERNAME: 镜像仓库密码

<img width="581" alt="image" src="https://github.com/user-attachments/assets/ecd9f847-c200-49c3-8d1c-7fbb3a87a7ff">

其中镜像仓库可以通过阿里云获得。访问 https://cr.console.aliyun.com/ 扫码登录后进入个人实例,创建一个命名空间,例如yourname,然后获取访问凭证

<img width="412" alt="image" src="https://github.com/user-attachments/assets/cad2a207-0ff3-4044-b9d8-0cded4ed7201">

然后,参照用法一启动工作流,注意选择Pull And Push版的

<img width="163" alt="image" src="https://github.com/user-attachments/assets/f52fdcd7-2cc3-402e-bd58-b701acc308aa">

工作流执行完毕后,就可以去自己的镜像仓库pull到本地了