Skip to content

Commit

Permalink
fix: yq shenanigans
Browse files Browse the repository at this point in the history
  • Loading branch information
callum-macd committed Jan 23, 2025
1 parent 85ed6cc commit fa9d36c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
35 changes: 18 additions & 17 deletions .github/workflows/mirror-dockerhub-ghcr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Docker Image Sync with Skopeo
on:
push:
branches:
- feat/CTO-844_basic_image_mirror # or any other trigger you prefer
- feat/CTO-844_basic_image_mirror

jobs:
sync_images:
Expand All @@ -24,29 +24,30 @@ jobs:
- name: Pull and Push Images
run: |
# File containing list of images
IMAGE_LIST="infra-images.yaml"
IMAGE_LIST="./infra-images.yaml"
# Loop through each registry and image in the YAML file
for registry in $(yq eval '. | keys | .[]' $IMAGE_LIST); do
for registry in $(yq '. | keys | .[]' "${IMAGE_LIST}"); do
# Loop through each image tag for this registry
for image in $(yq eval ".${registry}[]" $IMAGE_LIST); do
# Loop through each image tag for this registry
for image in $(yq ".${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)
# Extract the image tag (e.g., nginx:1.0.0)
# and strip quotes
registry=$(echo "${registry}" | tr -d '"')
tag=$(echo "${image}" | cut -d':' -f2 | tr -d '"')
image_name=$(echo "${image}" | cut -d':' -f1 | tr -d '"')
# Construct the full source image path
SOURCE_IMAGE="docker://$registry/$image_name:$tag"
# 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
# Define destination image on GHCR
GHCR_IMAGE="docker://ghcr.io/${{ github.repository_owner }}/${image_name}:${tag}"
# Copy the image from the source registry to GitHub Packages (GHCR)
echo "${SOURCE_IMAGE}" "${GHCR_IMAGE}"
done
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions infra-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ docker.io:
# - sonatype/nexus3:3.75.1
# - velero/velero-plugin-for-aws:v1.10.1
# - velero/velero:v1.14.1
# xpkg.upbound.io:
# - crossplane-contrib/function-go-templating:v0.8.0
xpkg.upbound.io:
- crossplane-contrib/function-go-templating:v0.8.0
# - crossplane-contrib/function-patch-and-transform:v0.2.1
# - crossplane-contrib/provider-ansible:v0.6.0
# - crossplane-contrib/provider-aws:v0.49.2
Expand Down

0 comments on commit fa9d36c

Please sign in to comment.