close-prs #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: close-prs | |
| on: | |
| schedule: | |
| - cron: "0 22 * * *" # Daily at 10:00 PM UTC | |
| workflow_dispatch: | |
| inputs: | |
| dry-run: | |
| description: "Log matching PRs without closing them" | |
| type: boolean | |
| default: true | |
| max-close: | |
| description: "Maximum matching PRs to close" | |
| type: string | |
| required: false | |
| default: "50" | |
| jobs: | |
| close: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 240 | |
| permissions: | |
| contents: read | |
| issues: write | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | |
| - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 | |
| with: | |
| bun-version: latest | |
| - name: Close old PRs without enough positive reactions | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| run: | | |
| max_close="${{ inputs['max-close'] }}" | |
| if [ -z "$max_close" ]; then | |
| max_close="50" | |
| fi | |
| args=("--threshold" "2" "--age-months" "1" "--sleep-ms" "20000" "--max-close" "$max_close") | |
| if [ "${{ github.event_name }}" = "schedule" ]; then | |
| args+=("--execute") | |
| elif [ "${{ inputs['dry-run'] }}" = "false" ]; then | |
| args+=("--execute") | |
| fi | |
| bun script/github/close-prs.ts "${args[@]}" |