# Cleanup old generated docs previews name: Cleanup on: schedule: # 06:50 UTC every Monday - cron: '50 6 * * 1' workflow_dispatch: concurrency: group: cleanup-${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: clean_docs_branch: timeout-minutes: 45 permissions: issues: write contents: write runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v6 with: ref: generated-docs-preview - name: Clean docs branch run: | cd pr/ # keep the last 10 prs dirs=$(ls -1d [0-9]* | sort -n) total_dirs=$(echo "$dirs" | wc -l) dirs_to_remove=$(echo "$dirs" | head -n $(($total_dirs - 10))) if [ -n "$dirs_to_remove" ]; then echo "$dirs_to_remove" | xargs rm -rf fi git add . git commit -m "Cleanup old docs" || true git push || true