Close Invalid Threads #197
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 Invalid Threads | |
on: | |
schedule: | |
- cron: '0 1 * * *' | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
close-issues: | |
runs-on: ubuntu-latest | |
if: github.repository == 'Paperback-iOS/website' | |
permissions: | |
contents: read | |
issues: write | |
steps: | |
- name: Close Issues | |
run: | | |
DATE=$(date --date='7 days ago' --iso-8601) | |
close_issues() { | |
echo "Closing issues marked as '$1'." | |
for issue in $(gh issue list --limit 100 --label "$1" --repo ${{ github.repository }} --state open --search "updated:<$DATE" --json number --jq '.[].number'); do | |
echo "Closing https://github.com/${{ github.repository }}/issues/$issue" | |
gh issue close $issue --repo ${{ github.repository }} --reason "not planned" --comment "This issue has been marked as \"$1\" and has seen no recent activity. It has been automatically closed for house-keeping purposes." | |
done | |
} | |
close_issues "duplicate" | |
close_issues "wont fix" | |
close_issues "invalid" | |
- name: Close Pull Requests | |
run: | | |
DATE=$(date --date='7 days ago' --iso-8601) | |
close_prs() { | |
echo "Closing pull requests marked as '$1'." | |
for pr in $(gh pr list --limit 100 --label "$1" --repo ${{ github.repository }} --state open --search "updated:<$DATE" --json number --jq '.[].number'); do | |
echo "Closing https://github.com/${{ github.repository }}/pull/$pr" | |
gh pr close $pr --repo ${{ github.repository }} --comment "This pull request has been marked as \"$1\" and has seen no recent activity. It has been automatically closed for house-keeping purposes." | |
done | |
} | |
close_prs "duplicate" | |
close_prs "wont fix" | |
close_prs "invalid" |