Close Old PRs #188
This file contains 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 Old PRs | |
on: | |
schedule: | |
- cron: "0 0 * * *" # Runs daily at midnight | |
workflow_dispatch: # Allows manual triggering of the workflow | |
jobs: | |
close_old_prs: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Close old PRs | |
id: close_prs | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
pr_list=$(gh pr list --state open --json number,createdAt --jq '.[] | select((now - (.createdAt | fromdateiso8601)) > (2 * 24 * 60 * 60)) | .number') | |
closed_prs="" | |
for pr in $pr_list; do | |
gh pr close $pr -c "Closing this PR as it has been open for more than 2 days." | |
closed_prs="$closed_prs $pr" | |
done | |
echo "closed_prs=$closed_prs" >> $GITHUB_ENV | |
- name: Output closed PRs | |
run: | | |
echo "Closed PRs: $closed_prs" | |
env: | |
closed_prs: ${{ env.closed_prs }} |