name: Cleanup (cron)
on:
  schedule:
    - cron: '30 10 * * SUN' # every sunday at 10:30

jobs:
  deleteArtifacts:
    runs-on: ubuntu-latest
    steps:
      - name: Delete old artifacts
        uses: kolpav/purge-artifacts-action@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          expire-in: 21 days
  cleanupCloudRunner:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        if: github.event.event_type != 'pull_request_target'
        with:
          lfs: true
      - uses: actions/setup-node@v4
        with:
          node-version: '18'
      - run: yarn
      - run: yarn run cli --help
        env:
          AWS_REGION: eu-west-2
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          AWS_DEFAULT_REGION: eu-west-2
      - run: yarn run cli -m list-resources
        env:
          AWS_REGION: eu-west-2
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          AWS_DEFAULT_REGION: eu-west-2
