name: Cleanup old dev images

on:
  schedule:
    # Weekly on Sunday at 6 AM UTC
    - cron: '0 6 * * 0'
  workflow_dispatch:

jobs:
  cleanup:
    if: github.repository == 'Nezreka/SoulSync'
    runs-on: ubuntu-latest
    permissions:
      packages: write

    steps:
      - name: Delete old dev image tags
        uses: actions/delete-package-versions@v5
        with:
          package-name: soulsync
          package-type: container
          min-versions-to-keep: 10
          delete-only-pre-release-versions: false
          # Only prune tags matching the dev nightly pattern (keep rolling + version tags)
          ignore-versions: '^(dev|nightly|latest|\\d+\\.\\d+)$'
