Skip to content

Commit

Permalink
chore: add skopeo for ecr (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
JashBook authored Dec 27, 2023
1 parent 9482a55 commit d13cbad
Show file tree
Hide file tree
Showing 11 changed files with 139 additions and 49 deletions.
23 changes: 18 additions & 5 deletions .github/utils/skopeo_copy_to_aliyun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ALIYUN_USERNAME=$1
ALIYUN_PASSWORD=$2
FILE_NAME=$3
REGISTRY=$4
ECR_PASSWORD=$5
ECR_USER=AWS

if [[ -z "$REGISTRY" ]]; then
REGISTRY=docker.io
Expand All @@ -15,12 +17,23 @@ do
skopeo_msg="skopeo copy $REGISTRY/$image to registry.cn-hangzhou.aliyuncs.com/apecloud/$image_name"
echo "$skopeo_msg"
skopeo_flag=0
ret_msg=""
for i in {1..10}; do
ret_msg=$(skopeo copy --all \
--dest-username "$ALIYUN_USERNAME" \
--dest-password "$ALIYUN_PASSWORD" \
docker://$REGISTRY/$image \
docker://registry.cn-hangzhou.aliyuncs.com/apecloud/$image_name)
if [[ "${REGISTRY}" == *"ecr"* ]]; then
ret_msg=$(skopeo copy --all \
--dest-username "$ALIYUN_USERNAME" \
--dest-password "$ALIYUN_PASSWORD" \
--src-username "$ECR_USER" \
--src-password "$ECR_PASSWORD" \
docker://$REGISTRY/$image \
docker://registry.cn-hangzhou.aliyuncs.com/apecloud/$image_name)
else
ret_msg=$(skopeo copy --all \
--dest-username "$ALIYUN_USERNAME" \
--dest-password "$ALIYUN_PASSWORD" \
docker://$REGISTRY/$image \
docker://registry.cn-hangzhou.aliyuncs.com/apecloud/$image_name)
fi
echo "return message:$ret_msg"
if [[ "$ret_msg" == *"Storing list signatures"* || "$ret_msg" == *"Skipping"* ]]; then
echo "$(tput -T xterm setaf 2)$skopeo_msg success$(tput -T xterm sgr0)"
Expand Down
23 changes: 18 additions & 5 deletions .github/utils/skopeo_copy_to_aliyun_new.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ALIYUN_USERNAME=$1
ALIYUN_PASSWORD=$2
FILE_NAME=$3
REGISTRY=$4
ECR_PASSWORD=$5
ECR_USER=AWS

if [[ -z "$REGISTRY" ]]; then
REGISTRY=docker.io
Expand All @@ -15,12 +17,23 @@ do
skopeo_msg="skopeo copy $REGISTRY/$image to infracreate-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud/$image_name"
echo "$skopeo_msg"
skopeo_flag=0
ret_msg=""
for i in {1..10}; do
ret_msg=$( skopeo copy --all \
--dest-username "$ALIYUN_USERNAME" \
--dest-password "$ALIYUN_PASSWORD" \
docker://$REGISTRY/$image \
docker://infracreate-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud/$image_name)
if [[ "${REGISTRY}" == *"ecr"* ]]; then
ret_msg=$(skopeo copy --all \
--dest-username "$ALIYUN_USERNAME" \
--dest-password "$ALIYUN_PASSWORD" \
--src-username "$ECR_USER" \
--src-password "$ECR_PASSWORD" \
docker://$REGISTRY/$image \
docker://infracreate-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud/$image_name)
else
ret_msg=$(skopeo copy --all \
--dest-username "$ALIYUN_USERNAME" \
--dest-password "$ALIYUN_PASSWORD" \
docker://$REGISTRY/$image \
docker://infracreate-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud/$image_name)
fi
echo "return message:$ret_msg"
if [[ "$ret_msg" == *"Storing list signatures"* || "$ret_msg" == *"Skipping"* ]]; then
echo "$(tput -T xterm setaf 2)$skopeo_msg success$(tput -T xterm sgr0)"
Expand Down
23 changes: 18 additions & 5 deletions .github/utils/skopeo_copy_to_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ DOCKER_USERNAME=$1
DOCKER_PASSWORD=$2
FILE_NAME=$3
REGISTRY=$4
ECR_PASSWORD=$5
ECR_USER=AWS

if [[ -z "$REGISTRY" ]]; then
REGISTRY=docker.io
Expand All @@ -15,12 +17,23 @@ do
skopeo_msg="skopeo copy $REGISTRY/$image to docker.io/apecloud/$image_name"
echo "$skopeo_msg"
skopeo_flag=0
ret_msg=""
for i in {1..10}; do
ret_msg=$( skopeo copy --all \
--dest-username "$DOCKER_USERNAME" \
--dest-password "$DOCKER_PASSWORD" \
docker://$REGISTRY/$image \
docker://docker.io/apecloud/$image_name)
if [[ "${REGISTRY}" == *"ecr"* ]]; then
ret_msg=$(skopeo copy --all \
--dest-username "$ALIYUN_USERNAME" \
--dest-password "$ALIYUN_PASSWORD" \
--src-username "$ECR_USER" \
--src-password "$ECR_PASSWORD" \
docker://$REGISTRY/$image \
docker://docker.io/apecloud/$image_name)
else
ret_msg=$( skopeo copy --all \
--dest-username "$DOCKER_USERNAME" \
--dest-password "$DOCKER_PASSWORD" \
docker://$REGISTRY/$image \
docker://docker.io/apecloud/$image_name)
fi
echo "return message:$ret_msg"
if [[ "$ret_msg" == *"Storing list signatures"* || "$ret_msg" == *"Skipping"* ]]; then
echo "$(tput -T xterm setaf 2)$skopeo_msg success$(tput -T xterm sgr0)"
Expand Down
33 changes: 24 additions & 9 deletions .github/utils/skopeo_sync_to_aliyun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ ALIYUN_USERNAME=$3
ALIYUN_PASSWORD=$4
FILE_NAME=$5
REGISTRY=$6
ECR_PASSWORD=$7
ECR_USER=AWS

if [[ -z "$REGISTRY" ]]; then
REGISTRY=docker.io
Expand All @@ -16,16 +18,29 @@ do
skopeo_msg="skopeo sync $REGISTRY/$image to registry.cn-hangzhou.aliyuncs.com/apecloud"
echo "$skopeo_msg"
skopeo_flag=0
ret_msg=""
for i in {1..10}; do
ret_msg=$(skopeo sync --all \
--src-username "$DOCKER_USERNAME" \
--src-password "$DOCKER_PASSWORD" \
--dest-username "$ALIYUN_USERNAME" \
--dest-password "$ALIYUN_PASSWORD" \
--src docker \
--dest docker \
$REGISTRY/$image \
registry.cn-hangzhou.aliyuncs.com/apecloud)
if [[ "${REGISTRY}" == *"ecr"* ]]; then
ret_msg=$(skopeo sync --all \
--src-username "$ECR_USER" \
--src-password "$ECR_PASSWORD" \
--dest-username "$ALIYUN_USERNAME" \
--dest-password "$ALIYUN_PASSWORD" \
--src docker \
--dest docker \
$REGISTRY/$image \
registry.cn-hangzhou.aliyuncs.com/apecloud)
else
ret_msg=$(skopeo sync --all \
--src-username "$DOCKER_USERNAME" \
--src-password "$DOCKER_PASSWORD" \
--dest-username "$ALIYUN_USERNAME" \
--dest-password "$ALIYUN_PASSWORD" \
--src docker \
--dest docker \
$REGISTRY/$image \
registry.cn-hangzhou.aliyuncs.com/apecloud)
fi
echo "return message:$ret_msg"
if [[ "$ret_msg" == *"Storing list signatures"* || "$ret_msg" == *"Skipping"* ]]; then
echo "$(tput -T xterm setaf 2)$skopeo_msg success$(tput -T xterm sgr0)"
Expand Down
33 changes: 24 additions & 9 deletions .github/utils/skopeo_sync_to_aliyun_new.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ ALIYUN_USERNAME=$3
ALIYUN_PASSWORD=$4
FILE_NAME=$5
REGISTRY=$6
ECR_PASSWORD=$7
ECR_USER=AWS

if [[ -z "$REGISTRY" ]]; then
REGISTRY=docker.io
Expand All @@ -16,16 +18,29 @@ do
skopeo_msg="skopeo sync $REGISTRY/$image to infracreate-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud"
echo "$skopeo_msg"
skopeo_flag=0
ret_msg=""
for i in {1..10}; do
ret_msg=$( skopeo sync --all \
--src-username "$DOCKER_USERNAME" \
--src-password "$DOCKER_PASSWORD" \
--dest-username "$ALIYUN_USERNAME" \
--dest-password "$ALIYUN_PASSWORD" \
--src docker \
--dest docker \
$REGISTRY/$image \
infracreate-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud)
if [[ "${REGISTRY}" == *"ecr"* ]]; then
ret_msg=$(skopeo sync --all \
--src-username "$ECR_USER" \
--src-password "$ECR_PASSWORD" \
--dest-username "$ALIYUN_USERNAME" \
--dest-password "$ALIYUN_PASSWORD" \
--src docker \
--dest docker \
$REGISTRY/$image \
infracreate-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud)
else
ret_msg=$( skopeo sync --all \
--src-username "$DOCKER_USERNAME" \
--src-password "$DOCKER_PASSWORD" \
--dest-username "$ALIYUN_USERNAME" \
--dest-password "$ALIYUN_PASSWORD" \
--src docker \
--dest docker \
$REGISTRY/$image \
infracreate-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud)
fi
echo "return message:$ret_msg"
if [[ "$ret_msg" == *"Storing list signatures"* || "$ret_msg" == *"Skipping"* ]]; then
echo "$(tput -T xterm setaf 2)$skopeo_msg success$(tput -T xterm sgr0)"
Expand Down
33 changes: 24 additions & 9 deletions .github/utils/skopeo_sync_to_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ DOCKER_USERNAME=$1
DOCKER_PASSWORD=$2
FILE_NAME=$3
REGISTRY=$4
ECR_PASSWORD=$5
ECR_USER=AWS

if [[ -z "$REGISTRY" ]]; then
REGISTRY=docker.io
Expand All @@ -14,16 +16,29 @@ do
skopeo_msg="skopeo sync $REGISTRY/$image to docker.io/apecloud"
echo "$skopeo_msg"
skopeo_flag=0
ret_msg=""
for i in {1..10}; do
ret_msg=$(skopeo sync --all \
--src-username "$DOCKER_USERNAME" \
--src-password "$DOCKER_PASSWORD" \
--dest-username "$DOCKER_USERNAME" \
--dest-password "$DOCKER_PASSWORD" \
--src docker \
--dest docker \
$REGISTRY/$image \
docker.io/apecloud)
if [[ "${REGISTRY}" == *"ecr"* ]]; then
ret_msg=$(skopeo sync --all \
--src-username "$ECR_USER" \
--src-password "$ECR_PASSWORD" \
--dest-username "$ALIYUN_USERNAME" \
--dest-password "$ALIYUN_PASSWORD" \
--src docker \
--dest docker \
$REGISTRY/$image \
docker.io/apecloud)
else
ret_msg=$(skopeo sync --all \
--src-username "$DOCKER_USERNAME" \
--src-password "$DOCKER_PASSWORD" \
--dest-username "$DOCKER_USERNAME" \
--dest-password "$DOCKER_PASSWORD" \
--src docker \
--dest docker \
$REGISTRY/$image \
docker.io/apecloud)
fi
echo "return message:$ret_msg"
if [[ "$ret_msg" == *"Storing list signatures"* || "$ret_msg" == *"Skipping"* ]]; then
echo "$(tput -T xterm setaf 2)$skopeo_msg success$(tput -T xterm sgr0)"
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/skopeo-copy-images-aliyun.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ jobs:
"${{ secrets.ALIYUN_REGISTRY_USER }}" \
"${{ secrets.ALIYUN_REGISTRY_PASSWORD }}" \
${{ github.workspace }}/.github/utils/images-list.txt \
"${{ github.event.inputs.registry }}"
"${{ inputs.registry }}" \
'${{ secrets.ECR_PASSWORD }}'
bash ${{ github.workspace }}/.github/utils/skopeo_copy_to_aliyun_new.sh \
"${{ secrets.ALIYUN_USER_NEW }}" \
"${{ secrets.ALIYUN_PASSWORD_NEW }}" \
${{ github.workspace }}/.github/utils/images-list.txt \
"${{ github.event.inputs.registry }}"
"${{ inputs.registry }}" \
'${{ secrets.ECR_PASSWORD }}'
3 changes: 2 additions & 1 deletion .github/workflows/skopeo-copy-images-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ jobs:
"${{ secrets.DOCKER_REGISTRY_USER }}" \
'${{ secrets.DOCKER_REGISTRY_PASSWORD }}' \
${{ github.workspace }}/.github/utils/images-list.txt \
"${{ github.event.inputs.registry }}"
"${{ inputs.registry }}" \
'${{ secrets.ECR_PASSWORD }}'
2 changes: 1 addition & 1 deletion .github/workflows/skopeo-sync-images-aliyun-to-aliyun.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ jobs:
"${{ secrets.ALIYUN_USER_NEW }}" \
"${{ secrets.ALIYUN_PASSWORD_NEW }}" \
${{ github.workspace }}/.github/utils/images-list.txt \
"${{ github.event.inputs.registry }}"
"${{ inputs.registry }}"
6 changes: 4 additions & 2 deletions .github/workflows/skopeo-sync-images-aliyun.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ jobs:
"${{ secrets.ALIYUN_REGISTRY_USER }}" \
"${{ secrets.ALIYUN_REGISTRY_PASSWORD }}" \
${{ github.workspace }}/.github/utils/images-list.txt \
"${{ github.event.inputs.registry }}"
"${{ inputs.registry }}" \
'${{ secrets.ECR_PASSWORD }}'
bash ${{ github.workspace }}/.github/utils/skopeo_sync_to_aliyun_new.sh \
"${{ secrets.DOCKER_USER }}" \
'${{ secrets.DOCKER_PASSWORD }}' \
"${{ secrets.ALIYUN_USER_NEW }}" \
"${{ secrets.ALIYUN_PASSWORD_NEW }}" \
${{ github.workspace }}/.github/utils/images-list.txt \
"${{ github.event.inputs.registry }}"
"${{ inputs.registry }}" \
'${{ secrets.ECR_PASSWORD }}'
3 changes: 2 additions & 1 deletion .github/workflows/skopeo-sync-images-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ jobs:
"${{ secrets.DOCKER_REGISTRY_USER }}" \
'${{ secrets.DOCKER_REGISTRY_PASSWORD }}' \
${{ github.workspace }}/.github/utils/images-list.txt \
"${{ github.event.inputs.registry }}"
"${{ inputs.registry }}" \
'${{ secrets.ECR_PASSWORD }}'

0 comments on commit d13cbad

Please sign in to comment.