# MotoVaultPro Base Image Mirroring Workflow
# Mirrors upstream Docker images to Gitea Package Registry
# Runs weekly on schedule or manual trigger

name: Mirror Base Images
run-name: Mirror Base Images to Registry

on:
  schedule:
    # Run every Sunday at 3:00 AM UTC
    - cron: '0 3 * * 0'
  workflow_dispatch:

env:
  REGISTRY: git.motovaultpro.com

jobs:
  mirror:
    name: Mirror Base Images
    runs-on: stage
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Login to Gitea Container Registry
        run: |
          echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login -u "${{ secrets.REGISTRY_USER }}" --password-stdin "$REGISTRY"

      - name: Run mirror script
        run: |
          chmod +x scripts/ci/mirror-base-images.sh
          REGISTRY=$REGISTRY/egullickson/mirrors ./scripts/ci/mirror-base-images.sh

      - name: Report results
        if: always()
        run: |
          echo "Base image mirroring complete"
          echo "Mirrored images available at: $REGISTRY/egullickson/mirrors/"
