-
Notifications
You must be signed in to change notification settings - Fork 2
/
action.yml
121 lines (105 loc) · 4.1 KB
/
action.yml
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: 'Docker Sync Action'
description: 'Keeps docker images in sync between registries or repositories'
author: 'Pavel Titenkov'
branding:
icon: 'package'
color: 'blue'
inputs:
source:
description: source image repository
required: true
destination:
description: destination image repository
required: true
source-transport:
description: source transport type (containers-storage,dir,docker,docker-archive,docker-daemon,oci,oci-archive,ostree,tarball)
required: false
default: docker
destination-transport:
description: destination transport type (containers-storage,dir,docker,docker-archive,docker-daemon,oci,oci-archive,ostree,tarball)
required: false
default: docker
source-credentials:
description: source credentials
required: false
default: 'null'
destination-credentials:
description: destination credentials
required: false
default: 'null'
source-tls:
description: require HTTPS and verify certificates when talking to the container registry or daemon
required: false
default: 'false'
destination-tls:
description: require HTTPS and verify certificates when talking to the container registry or daemon
required: false
default: 'false'
format:
description: MANIFEST TYPE (oci, v2s1, or v2s2) to use in the destination (default is manifest type of source, with fallbacks)
required: false
default: v2s2
versions:
description: docker image tags to sync (multi-line)
required: false
default: ''
runs:
using: composite
steps:
- id: sync
run: |
echo -e "${PURPLE}> 🚜 Syncing docker images ${BLANK}"
echo -e "${YELLOW}> Using skopeo version: ${BLANK}"
skopeo --version
if [ "${{ inputs.source-transport }}" = "dir" ]; then
SOURCE_DELIMITER=":/"
elif [ "${{ inputs.source-transport }}" = "docker" ]; then
SOURCE_DELIMITER="://"
else
SOURCE_DELIMITER=":"
fi
if [ "${{ inputs.destination-transport }}" = "dir" ]; then
DESTINATION_DELIMITER=":/"
elif [ "${{ inputs.destination-transport }}" = "docker" ]; then
DESTINATION_DELIMITER="://"
else
DESTINATION_DELIMITER=":"
fi
echo -e "${YELLOW}> 🐳 Docker source repository ${BLANK}"
skopeo inspect ${{ inputs.source-transport }}${SOURCE_DELIMITER}${{ inputs.source }} --tls-verify=${{ inputs.source-tls }} --creds=${{ inputs.source-credentials }}
echo -e "${YELLOW}> 📦 Transfer docker images from ${{ inputs.source }} to ${{ inputs.destination }} ${BLANK}"
if [ "${{ inputs.versions }}" = "" ]; then
skopeo sync --format ${{ inputs.format }} \
--src=${{ inputs.source-transport }} \
--src-tls-verify=${{ inputs.source-tls }} \
--src-creds=${{ inputs.source-credentials }} \
--dest=${{ inputs.destination-transport }} \
--dest-tls-verify=${{ inputs.destination-tls }} \
--dest-creds=${{ inputs.destination-credentials }} \
${{ inputs.source }} \
${{ inputs.destination }}
else
echo "${{ inputs.versions }}" | while read version ; do
if [ "$version" = "" ]; then
break
fi
echo -e "${YELLOW}> 📦 Transfer tag $version"
skopeo copy --format ${{ inputs.format }} \
--src-tls-verify=${{ inputs.source-tls }} \
--src-creds=${{ inputs.source-credentials }} \
--dest-tls-verify=${{ inputs.destination-tls }} \
--dest-creds=${{ inputs.destination-credentials }} \
${{ inputs.source-transport }}${SOURCE_DELIMITER}${{ inputs.source }}:$version \
${{ inputs.destination-transport }}${DESTINATION_DELIMITER}${{ inputs.destination }}:$version
done
fi
echo -e "${YELLOW}> ✅ Sync is complete. See details above ${BLANK}"
shell: bash
env:
RED: \033[1;31m
GREEN: \033[1;32m
YELLOW: \033[1;33m
BLUE: \033[1;34m
PURPLE: \033[1;35m
CYAN: \033[1;36m
BLANK: \033[0m