Files
Image_downloader/.gitea/workflows/image_downloader_runner.yaml
T
pierre.geeraert 8bd1ec52db
image puller runner / setup (push) Successful in 19s
image puller runner / Sync (${{ fromJSON(needs.setup.outputs.image_matrix) }}) (push) Successful in 1m2s
probably not needed
2026-09-24 10:40:11 +01:00

83 lines
2.6 KiB
YAML

name: image puller runner
run-name: Pull and Push 🚀
on:
push:
workflow_dispatch: # Enables the manual run UI button
jobs:
setup:
env:
RUNNER_TOOL_CACHE: /toolcache
container:
image: gitea.geeraert.eu/pi-ux-ce/custom-runner-debian-slim:latest
volumes:
- act-toolcache:/opt/hostedtoolcache # this is where Runner store their cache default
runs-on: host-runner
outputs:
image_matrix: ${{ steps.set-matrix.outputs.images }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Parse image file into JSON array
id: set-matrix
run: |
# Read lines, remove empty lines/comments, and format as a JSON array
# e.g., ["ubuntu:latest", "alpine:3.18"]
JSON_ARRAY=$(jq -R -s -c 'split("\n") | map(select(length > 0 and (startswith("#") | not)))' image_list.txt)
echo "Images found: $JSON_ARRAY"
echo "images=$JSON_ARRAY" >> $GITHUB_OUTPUT
# Job 2: Process each image in parallel matrix slots
process-images:
needs: setup
runs-on: host-runner
container:
image: gitea.geeraert.eu/pi-ux-ce/custom-runner-debian-slim:latest
strategy:
max-parallel: 1
fail-fast: false
matrix:
image: ${{ fromJSON(needs.setup.outputs.image_matrix) }}
name: Sync (${{ matrix.image }})
steps:
- name: Login to gitea
uses: docker/login-action@v3
with:
registry: gitea.geeraert.eu
username: ${{ secrets.USERNAME_GITEA }}
password: ${{ secrets.PASSWORD_GITEA }}
- name: docker pull ${{ matrix.image }}
run: docker pull ${{ matrix.image }}
- name: Process, Tag and Push to Gitea
run: |
RAW_IMAGE="${{ matrix.image }}"
# Clean up the image name string to prevent malformed targets
# e.g., converts 'ghcr.io/bitwarden/admin:2026.1.0' into 'bitwarden-admin:2026.1.0'
CLEANED_NAME=$(echo "$RAW_IMAGE" | sed -E 's|^[^/]*/||' | tr '/' '-')
TARGET_IMAGE="gitea.geeraert.eu/pi-ux-ce/${CLEANED_NAME}"
echo "Original: $RAW_IMAGE"
echo "Target Registry Image: $TARGET_IMAGE"
# Perform operations sequentially
docker tag "$RAW_IMAGE" "$TARGET_IMAGE"
docker push "$TARGET_IMAGE"
- name: Post Cleanup Host Storage
if: always()
run: |
CLEANED_NAME=$(echo "${{ matrix.image }}" | sed -E 's|^[^/]*/||' | tr '/' '-')
docker rmi "${{ matrix.image }}" || true
docker rmi "gitea.geeraert.eu/pi-ux-ce/${CLEANED_NAME}" || true