Add a script for cleaning up stale copybara PRs

This was tested locally over a smaller set of PRs, resulting in:
https://github.com/protocolbuffers/protobuf/pull/13557

PiperOrigin-RevId: 560124506
pull/13692/head
Mike Kruskal 2 years ago committed by Copybara-Service
parent e59301bc55
commit 28260474bf
  1. 23
      .github/workflows/janitor.yml

@ -0,0 +1,23 @@
name: Protobuf Janitor
on:
schedule:
# Run daily at 10 AM UTC (2 AM PDT)
- cron: 0 10 * * *
workflow_dispatch:
jobs:
stale-prs:
- name: Close Stale Copybara PRs
runs-on: ubuntu-latest
run: |
set -ex
STALE_PRS=$(gh pr list --author "app/copybara-service" --limit 500 \
--json "number" --search "updated:<=$(date --date="-7 day" +%F)" \
| jq ".[].number")
for pr in $(STALE_PRS); do
echo "Closing #$pr..."
gh pr close --comment "Auto-closing Copybara pull request" --delete-branch "$pr"
done
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading…
Cancel
Save