Skip to content

feat: CTO-844 run on branch to test #1

feat: CTO-844 run on branch to test

feat: CTO-844 run on branch to test #1

name: Docker Image Sync with Skopeo
on:
push:
branches:
- feat/CTO-844_basic_image_mirror # or any other trigger you prefer
jobs:
sync_images:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Skopeo and yq
run: |
sudo apt-get install -y skopeo
sudo apt-get install -y yq
- name: Login to GitHub Packages (GHCR)
run: echo ${{ secrets.GITHUB_TOKEN }} | skopeo login ghcr.io --username ${{ github.actor }} --password-stdin
- name: Pull and Push Images
run: |
# File containing list of images
IMAGE_LIST="infra-images.yaml"
# Loop through each registry and image in the YAML file
for registry in $(yq eval 'keys' $IMAGE_LIST); do
# Loop through each image and tag for this registry
for image in $(yq eval ".${registry}[]" $IMAGE_LIST); do
# Extract the image tag (e.g., nginx:latest)
tag=$(echo $image | cut -d':' -f2)
image_name=$(echo $image | cut -d':' -f1)
# Construct the full source image path
SOURCE_IMAGE="docker://$registry/$image_name:$tag"
# Define destination image on GHCR
GHCR_IMAGE="docker://ghcr.io/${{ github.repository_owner }}/infra/$image_name:$tag"
# Copy the image from the source registry to GitHub Packages (GHCR)
skopeo copy $SOURCE_IMAGE $GHCR_IMAGE
done
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}