sync to aliyun:grafana/alloy:v1.1.1 #146
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: A skopeo image to aliyun | |
on: | |
workflow_dispatch: | |
inputs: | |
images_name: | |
description: 'sync image src name (e.g. <namesapce>/<name>:<tag>)' | |
required: false | |
default: '' | |
registry: | |
description: 'sync image src registry(e.g. docker.io)' | |
required: false | |
default: 'docker.io' | |
run-name: sync to aliyun:${{ inputs.images_name }} | |
env: | |
ALIYUN_REGISTRY_URL: apecloud-registry.cn-zhangjiakou.cr.aliyuncs.com | |
ALIYUN_REGISTRY_URL_NEW: infracreate-registry.cn-zhangjiakou.cr.aliyuncs.com | |
DOCKER_USER: ${{ secrets.DOCKER_REGISTRY_USER }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} | |
ALIYUN_USER: ${{ secrets.ALIYUN_REGISTRY_USER }} | |
ALIYUN_PASSWORD: ${{ secrets.ALIYUN_REGISTRY_PASSWORD }} | |
ALIYUN_USER_NEW: ${{ secrets.ALIYUN_USER_NEW }} | |
ALIYUN_PASSWORD_NEW: ${{ secrets.ALIYUN_PASSWORD_NEW }} | |
ECR_PASSWORD: ${{ secrets.ECR_PASSWORD }} | |
jobs: | |
skopeo: | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: install skopeo | |
run: | | |
brew install skopeo | |
skopeo sync -h | |
if [[ -n "${{ inputs.images_name }}" ]];then | |
bash ${{ github.workspace }}/.github/utils/utils.sh \ | |
--type 26 \ | |
--images "${{ inputs.images_name }}" \ | |
--images-list ${{ github.workspace }}/.github/utils/images-list.txt | |
fi | |
- name: check images exists | |
id: check_image_exists | |
continue-on-error: true | |
run: | | |
SKEPEO_TOOL="copy" | |
echo "skopeo-tool=${SKEPEO_TOOL}" >> $GITHUB_OUTPUT | |
IMAGE_NAME="${{ inputs.images_name }}" | |
IMAGE_NAME=${IMAGE_NAME##*/} | |
IMAGE_NAME=${IMAGE_NAME%:*} | |
LIST_IMAGE_NAME="${{ env.ALIYUN_REGISTRY_URL }}/apecloud/${IMAGE_NAME}" | |
for i in {1..3}; do | |
LIST_TAGS="$( skopeo list-tags docker://${LIST_IMAGE_NAME} )" | |
if [[ -n "${LIST_TAGS}" ]]; then | |
SKEPEO_TOOL="sync" | |
break | |
fi | |
sleep 1 | |
done | |
echo "skopeo-tool=${SKEPEO_TOOL}" >> $GITHUB_OUTPUT | |
- name: skopeo sync images | |
if: ${{ steps.check_image_exists.outputs.skopeo-tool == 'sync' }} | |
run: | | |
bash ${{ github.workspace }}/.github/utils/skopeo_sync_to_aliyun.sh \ | |
"${{ env.DOCKER_USER }}" \ | |
'${{ env.DOCKER_PASSWORD }}' \ | |
"${{ env.ALIYUN_USER }}" \ | |
"${{ env.ALIYUN_PASSWORD }}" \ | |
${{ github.workspace }}/.github/utils/images-list.txt \ | |
"${{ inputs.registry }}" \ | |
'${{ env.ECR_PASSWORD }}' | |
if [[ -n "${{ env.ALIYUN_USER_NEW }}" && -n "${{ env.ALIYUN_PASSWORD_NEW }}" ]]; then | |
bash ${{ github.workspace }}/.github/utils/skopeo_sync_to_aliyun_new.sh \ | |
"${{ env.DOCKER_USER }}" \ | |
'${{ env.DOCKER_PASSWORD }}' \ | |
"${{ env.ALIYUN_USER_NEW }}" \ | |
"${{ env.ALIYUN_PASSWORD_NEW }}" \ | |
${{ github.workspace }}/.github/utils/images-list.txt \ | |
"${{ inputs.registry }}" \ | |
'${{ env.ECR_PASSWORD }}' | |
fi | |
- name: skopeo copy images | |
if: ${{ steps.check_image_exists.outputs.skopeo-tool == 'copy' }} | |
run: | | |
bash ${{ github.workspace }}/.github/utils/skopeo_copy_to_aliyun.sh \ | |
"${{ env.ALIYUN_USER }}" \ | |
"${{ env.ALIYUN_PASSWORD }}" \ | |
${{ github.workspace }}/.github/utils/images-list.txt \ | |
"${{ inputs.registry }}" \ | |
'${{ env.ECR_PASSWORD }}' | |
if [[ -n "${{ env.ALIYUN_USER_NEW }}" && -n "${{ env.ALIYUN_PASSWORD_NEW }}" ]]; then | |
bash ${{ github.workspace }}/.github/utils/skopeo_copy_to_aliyun_new.sh \ | |
"${{ env.ALIYUN_USER_NEW }}" \ | |
"${{ env.ALIYUN_PASSWORD_NEW }}" \ | |
${{ github.workspace }}/.github/utils/images-list.txt \ | |
"${{ inputs.registry }}" \ | |
'${{ env.ECR_PASSWORD }}' | |
fi |