Add new sync image template (#3391)
This commit is contained in:
parent
a345b56c3e
commit
b971e619af
|
@ -0,0 +1,18 @@
|
||||||
|
name: Sync Image
|
||||||
|
description: 同步一个镜像
|
||||||
|
labels:
|
||||||
|
- sync image
|
||||||
|
body:
|
||||||
|
- type: checkboxes
|
||||||
|
id: checkboxes
|
||||||
|
attributes:
|
||||||
|
label: 单次单镜像同步
|
||||||
|
description: 请在标题上填入你要同步的 Image
|
||||||
|
options:
|
||||||
|
- label: 确保包含域名, 如 docker.io/, registry.k8s.io/, 如果不包含域名的请填入默认的 docker.io/
|
||||||
|
- label: 确保包含镜像的 tag, 如 :latest
|
||||||
|
- label: 请确保这个镜像真实存在
|
||||||
|
- label: 举个例子
|
||||||
|
- label: 如 docker.io/library/busybox:latest
|
||||||
|
- label: 如 docker.io/kindest/node:v1.30.0
|
||||||
|
- label: 如 registry.k8s.io/kubectl:v1.30.0
|
|
@ -1,4 +1,4 @@
|
||||||
name: Target Sync Image
|
name: Target Sync Image (old)
|
||||||
on:
|
on:
|
||||||
issues:
|
issues:
|
||||||
types:
|
types:
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
name: Target Sync Image
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
|
||||||
|
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
|
||||||
|
permissions:
|
||||||
|
issues: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sync:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: contains(github.event.issue.labels.*.name, 'sync image')
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Check Issue
|
||||||
|
env:
|
||||||
|
MESSAGE: "${{ github.event.issue.body }}"
|
||||||
|
run: |
|
||||||
|
ORIGIN_IMAGE=$(echo ${{ github.event.issue.title }})
|
||||||
|
if [[ -z "${ORIGIN_IMAGE}" ]]; then
|
||||||
|
gh issue comment ${{ github.event.issue.number }} -b "找不到镜像呢"
|
||||||
|
gh issue edit ${{ github.event.issue.number }} --add-label "sync image failure"
|
||||||
|
gh issue close ${{ github.event.issue.number }} --reason "not planned"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ "${ORIGIN_IMAGE}" != *":"* ]]; then
|
||||||
|
gh issue comment ${{ github.event.issue.number }} -b "镜像 ${ORIGIN_IMAGE} 不存在呢, 请指定 tag, 如: ${ORIGIN_IMAGE}:latest"
|
||||||
|
gh issue edit ${{ github.event.issue.number }} --add-label "sync image failure"
|
||||||
|
gh issue close ${{ github.event.issue.number }} --reason "not planned"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ "${ORIGIN_IMAGE%%/*}" != *"."* ]]; then
|
||||||
|
gh issue comment ${{ github.event.issue.number }} -b "镜像 ${ORIGIN_IMAGE} 不存在呢, 请指定域名, 如: docker.io/${ORIGIN_IMAGE}"
|
||||||
|
gh issue edit ${{ github.event.issue.number }} --add-label "sync image failure"
|
||||||
|
gh issue close ${{ github.event.issue.number }} --reason "not planned"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
- name: Set up skopeo
|
||||||
|
run: |
|
||||||
|
wget https://github.com/lework/skopeo-binary/releases/download/v1.13.3/skopeo-linux-amd64 -O /usr/local/bin/skopeo && chmod +x /usr/local/bin/skopeo
|
||||||
|
skopeo --version
|
||||||
|
- name: Check Image
|
||||||
|
env:
|
||||||
|
MESSAGE: "${{ github.event.issue.body }}"
|
||||||
|
run: |
|
||||||
|
ORIGIN_IMAGE=$(echo ${{ github.event.issue.title }})
|
||||||
|
gh issue comment ${{ github.event.issue.number }} -b "镜像 ${ORIGIN_IMAGE} 同步中...<br>[详情请查看](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})"
|
||||||
|
- name: Start Proxy
|
||||||
|
env:
|
||||||
|
only_proxy: "m.daocloud.io"
|
||||||
|
run: |
|
||||||
|
wget https://github.com/wzshiming/bridge/releases/download/v0.9.0/bridge_linux_amd64 -O /usr/local/bin/bridge && chmod +x /usr/local/bin/bridge
|
||||||
|
nohup /usr/local/bin/bridge -b :8080 -p - ${{ secrets.PROTOCOL }} 2>/dev/null &
|
||||||
|
- name: Check Proxy
|
||||||
|
run: |
|
||||||
|
curl -v http://127.0.0.1:8080 || exit 1
|
||||||
|
curl -f --proxy 127.0.0.1:8080 -v http://m.daocloud.io/v2/ || exit 1
|
||||||
|
- name: Sync Images
|
||||||
|
env:
|
||||||
|
INCREMENTAL: "true"
|
||||||
|
SYNC: "true"
|
||||||
|
PARALLET: "1"
|
||||||
|
http_proxy: socks5://127.0.0.1:8080
|
||||||
|
https_proxy: socks5://127.0.0.1:8080
|
||||||
|
MESSAGE: "${{ github.event.issue.body }}"
|
||||||
|
run: |
|
||||||
|
ORIGIN_IMAGE=$(echo ${{ github.event.issue.title }})
|
||||||
|
./hack/diff-image.sh "${ORIGIN_IMAGE}" "m.daocloud.io/${ORIGIN_IMAGE}"
|
||||||
|
gh issue comment ${{ github.event.issue.number }} -b "镜像 ${ORIGIN_IMAGE} 同步完成<br>请使用 m.daocloud.io/${ORIGIN_IMAGE} 替代源镜像"
|
||||||
|
gh issue edit ${{ github.event.issue.number }} --add-label "sync image succeeded"
|
||||||
|
gh issue close ${{ github.event.issue.number }} --reason "completed"
|
||||||
|
|
||||||
|
- name: Fail Sync
|
||||||
|
if: failure()
|
||||||
|
env:
|
||||||
|
MESSAGE: "${{ github.event.issue.body }}"
|
||||||
|
run: |
|
||||||
|
ORIGIN_IMAGE=$(echo ${{ github.event.issue.title }})
|
||||||
|
gh issue comment ${{ github.event.issue.number }} -b "镜像 ${ORIGIN_IMAGE} 同步失败<br>[详情请查看](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})"
|
||||||
|
gh issue edit ${{ github.event.issue.number }} --add-label "sync image failure"
|
Loading…
Reference in New Issue