-
Notifications
You must be signed in to change notification settings - Fork 3
61 lines (49 loc) · 1.76 KB
/
Copy pathsync-drone-server.yml
File metadata and controls
61 lines (49 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Sync Drone Server
on:
push:
branches:
- main
paths:
- '.github/workflows/sync-drone-server.yml'
workflow_dispatch:
concurrency:
group: sync-drone-server-${{ github.ref }}
cancel-in-progress: true
jobs:
sync:
runs-on: ubuntu-latest
strategy:
max-parallel: 2
matrix:
version:
- "2"
- "2.28.2"
steps:
- name: Install skopeo
run: |
sudo apt-get update
sudo apt-get install -y skopeo
- name: Login to cloud
env:
REGISTRY: ${{ secrets.ALI_DOCKER_REPO }}
USERNAME: ${{ secrets.ALI_DOCKER_USER }}
PASSWORD: ${{ secrets.ALI_DOCKER_PASS }}
run: |
echo "$PASSWORD" | skopeo login --username "$USERNAME" --password-stdin "$REGISTRY"
- name: Copy drone/drone:${{ matrix.version }} (skopeo)
env:
SRC: ${{ secrets.DOCKERHUB_MIRROR }}/drone/drone:${{ matrix.version }}
DST: ${{ secrets.ALI_DOCKER_REPO }}/mirrors_hub/drone_server:${{ matrix.version }}
run: |
set -o pipefail
SRC_DIGEST="$(skopeo inspect --override-arch amd64 --override-os linux --format '{{.Digest}}' "docker://$SRC" 2>/dev/null || true)"
if [ -z "$SRC_DIGEST" ]; then
echo "Failed to resolve source digest: $SRC"
exit 1
fi
DST_DIGEST="$(skopeo inspect --override-arch amd64 --override-os linux --format '{{.Digest}}' "docker://$DST" 2>/dev/null || true)"
if [ -n "$DST_DIGEST" ] && [ "$SRC_DIGEST" = "$DST_DIGEST" ]; then
echo "Digest unchanged ($SRC_DIGEST), skip sync."
exit 0
fi
skopeo copy --override-arch amd64 --override-os linux --retry-times 3 "docker://$SRC" "docker://$DST"