Update Sync (#36765)

This commit is contained in:
Shiming Zhang 2024-12-20 13:51:45 +08:00 committed by GitHub
parent 89369a6deb
commit e7678e9589
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 41 additions and 90 deletions

View File

@ -1,4 +1,5 @@
name: Manual Deep Sync name: Manual Deep Sync
run-name: Manual Deep Sync ${{ inputs.image }} by @${{ github.actor }}
on: on:
workflow_dispatch: workflow_dispatch:
@ -10,34 +11,15 @@ on:
jobs: jobs:
sync-images: sync-images:
if: github.repository == 'DaoCloud/public-image-mirror'
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.repository == 'DaoCloud/public-image-mirror'
steps: steps:
- name: Checkout repository - name: Set up crproxy
uses: actions/checkout@v4
- name: Start Proxy
env:
only_proxy: "m.daocloud.io"
run: | 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 wget https://github.com/DaoCloud/crproxy/releases/download/v0.13.0-alpha.43/crproxy_linux_amd64 -O /usr/local/bin/crproxy && chmod +x /usr/local/bin/crproxy
nohup /usr/local/bin/bridge -b :8080 -p - ${{ secrets.PROTOCOL }} 2>/dev/null &
- name: Check Proxy - name: Sync Images to OSS&OBS
run: | run: |
curl -v http://127.0.0.1:8080 || exit 1 ORIGIN_IMAGE=${{ github.event.inputs.image }}
curl -f --proxy 127.0.0.1:8080 -v http://m.daocloud.io/v2/ || exit 1 /usr/local/bin/crproxy sync --deep --max-warn 1 ${{ secrets.STORAGE_ARGS }} --user '${{ secrets.OCI_USER }}' --list ${ORIGIN_IMAGE}
- name: Override mirror.txt
run: |
echo ${{ github.event.inputs.image }} > mirror.txt
- 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: 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
run: |
./hack/diff.sh

View File

@ -1,4 +1,5 @@
name: Manual Sync name: Manual Sync
run-name: Manual Sync ${{ inputs.image }} by @${{ github.actor }}
on: on:
workflow_dispatch: workflow_dispatch:
@ -10,35 +11,15 @@ on:
jobs: jobs:
sync-images: sync-images:
if: github.repository == 'DaoCloud/public-image-mirror'
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.repository == 'DaoCloud/public-image-mirror'
steps: steps:
- name: Checkout repository - name: Set up crproxy
uses: actions/checkout@v4
- name: Start Proxy
env:
only_proxy: "m.daocloud.io"
run: | 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 wget https://github.com/DaoCloud/crproxy/releases/download/v0.13.0-alpha.43/crproxy_linux_amd64 -O /usr/local/bin/crproxy && chmod +x /usr/local/bin/crproxy
nohup /usr/local/bin/bridge -b :8080 -p - ${{ secrets.PROTOCOL }} 2>/dev/null &
- name: Check Proxy - name: Sync Images to OSS&OBS
run: | run: |
curl -v http://127.0.0.1:8080 || exit 1 ORIGIN_IMAGE=${{ github.event.inputs.image }}
curl -f --proxy 127.0.0.1:8080 -v http://m.daocloud.io/v2/ || exit 1 /usr/local/bin/crproxy sync --max-warn 1 ${{ secrets.STORAGE_ARGS }} --user '${{ secrets.OCI_USER }}' --list ${ORIGIN_IMAGE}
- name: Override mirror.txt
run: |
echo ${{ github.event.inputs.image }} > mirror.txt
- 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: Sync Images
env:
INCREMENTAL: "true"
QUICKLY: "true"
SYNC: "true"
PARALLET: "1"
http_proxy: socks5://127.0.0.1:8080
https_proxy: socks5://127.0.0.1:8080
run: |
./hack/diff.sh

View File

@ -2,38 +2,23 @@ name: Sync
on: on:
schedule: schedule:
- cron: "0 12,18 * * *" - cron: "1 * * * *"
workflow_dispatch: workflow_dispatch:
jobs: jobs:
sync-images: sync-images:
if: github.repository == 'DaoCloud/public-image-mirror'
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.repository == 'DaoCloud/public-image-mirror'
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Start Proxy
env: - name: Set up crproxy
only_proxy: "m.daocloud.io"
run: | 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 wget https://github.com/DaoCloud/crproxy/releases/download/v0.13.0-alpha.43/crproxy_linux_amd64 -O /usr/local/bin/crproxy && chmod +x /usr/local/bin/crproxy
nohup /usr/local/bin/bridge -b :8080 -p - ${{ secrets.PROTOCOL }} 2>/dev/null &
- name: Check Proxy - name: Sync Images to OSS&OBS
run: | run: |
curl -v http://127.0.0.1:8080 || exit 1 ORIGIN_IMAGE=$(echo "${MESSAGE}" | grep SYNC | awk '{print $2}' | head -n 1 | sed "s/\r//g")
curl -f --proxy 127.0.0.1:8080 -v http://m.daocloud.io/v2/ || exit 1 /usr/local/bin/crproxy sync --max-warn 100 ${{ secrets.STORAGE_ARGS }} --list-from-file ./mirror.txt
- 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: Sync Images
env:
INCREMENTAL: "true"
QUICKLY: "true"
SYNC: "true"
PARALLET: "2"
http_proxy: socks5://127.0.0.1:8080
https_proxy: socks5://127.0.0.1:8080
run: |
./hack/diff.sh

View File

@ -1,4 +1,6 @@
name: Target Sync Image (old) name: Target Sync Image (old)
run-name: Target ${{ github.event.issue.title }} by @${{ github.actor }}
on: on:
issues: issues:
types: types:
@ -50,18 +52,14 @@ jobs:
- name: Set up crproxy - name: Set up crproxy
run: | run: |
wget https://github.com/DaoCloud/crproxy/releases/download/v0.8.0/crproxy_linux_amd64 -O /usr/local/bin/crproxy && chmod +x /usr/local/bin/crproxy wget https://github.com/DaoCloud/crproxy/releases/download/v0.13.0-alpha.43/crproxy_linux_amd64 -O /usr/local/bin/crproxy && chmod +x /usr/local/bin/crproxy
/usr/local/bin/crproxy -a :8000 ${{ secrets.CRPROXY_ARGS }} &
- name: Sync Images - name: Sync Images to OSS&OBS
env: env:
MESSAGE: "${{ github.event.issue.body }}" MESSAGE: "${{ github.event.issue.body }}"
run: | run: |
ORIGIN_IMAGE=$(echo "${MESSAGE}" | grep SYNC | awk '{print $2}' | head -n 1 | sed "s/\r//g") ORIGIN_IMAGE=$(echo "${MESSAGE}" | grep SYNC | awk '{print $2}' | head -n 1 | sed "s/\r//g")
curl --fail -X PUT "http://127.0.0.1:8000/internal/api/image/sync?image=${ORIGIN_IMAGE}" /usr/local/bin/crproxy sync --deep --max-warn 1 ${{ secrets.STORAGE_ARGS }} --user '${{ secrets.OCI_USER }}' --list ${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" -b "IMAGE SYNC"
gh issue close ${{ github.event.issue.number }} --reason "completed"
- name: Fail Sync - name: Fail Sync
if: failure() if: failure()

View File

@ -1,4 +1,6 @@
name: Target Sync Image name: Target Sync Image
run-name: Target Sync ${{ github.event.issue.title }} by @${{ github.actor }}
on: on:
issues: issues:
types: types:
@ -49,13 +51,16 @@ jobs:
- name: Set up crproxy - name: Set up crproxy
run: | run: |
wget https://github.com/DaoCloud/crproxy/releases/download/v0.8.0/crproxy_linux_amd64 -O /usr/local/bin/crproxy && chmod +x /usr/local/bin/crproxy wget https://github.com/DaoCloud/crproxy/releases/download/v0.13.0-alpha.43/crproxy_linux_amd64 -O /usr/local/bin/crproxy && chmod +x /usr/local/bin/crproxy
/usr/local/bin/crproxy -a :8000 ${{ secrets.CRPROXY_ARGS }} &
- name: Sync Images - name: Sync Images to OSS&OBS
run: |
ORIGIN_IMAGE="${{ steps.get-image.outputs.image }}"
/usr/local/bin/crproxy sync --deep --max-warn 1 ${{ secrets.STORAGE_ARGS }} --user '${{ secrets.OCI_USER }}' --list ${ORIGIN_IMAGE}
- name: Succeeded Sync
run: | run: |
ORIGIN_IMAGE="${{ steps.get-image.outputs.image }}" ORIGIN_IMAGE="${{ steps.get-image.outputs.image }}"
curl --fail -X PUT "http://127.0.0.1:8000/internal/api/image/sync?image=${ORIGIN_IMAGE}"
gh issue comment ${{ github.event.issue.number }} -b "镜像 ${ORIGIN_IMAGE} 同步完成<br>请使用 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" -b "IMAGE SYNC" gh issue edit ${{ github.event.issue.number }} --add-label "sync image succeeded" -b "IMAGE SYNC"
gh issue close ${{ github.event.issue.number }} --reason "completed" gh issue close ${{ github.event.issue.number }} --reason "completed"