name: Cleanup Skipped Runs

on:
  schedule:
    - cron: '0 0 * * 0' # 毎週日曜 UTC 0:00
  workflow_dispatch: # 手動実行も可能

jobs:
  cleanup:
    runs-on: ubuntu-latest
    permissions:
      actions: write
    steps:
      - name: Delete skipped TAKT Action runs
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GH_REPO: ${{ github.repository }}
        run: |
          gh run list --workflow=takt-action.yml --status=skipped --limit=100 --json databaseId --jq '.[].databaseId' | \
            xargs -I {} gh run delete {}
