name: Blob Cleanup

on:
  schedule:
    # Run daily at 04:00 UTC
    - cron: '0 4 * * *'
  workflow_dispatch:  # Allow manual trigger

permissions:
  contents: read

jobs:
  cleanup:
    runs-on: [self-hosted, bazel]

    steps:
      - uses: actions/checkout@v6
        with:
          lfs: false
          clean: false

      - name: Clean up unreferenced blobs
        env:
          ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY_ID }}
          SECRET_KEY: ${{ secrets.SECRET_KEY }}
        run: |
          bazel run //src/main/go/net/eagle0/build/blob_cleanup:blob_cleanup -- --min-age=1h
