-
-
Notifications
You must be signed in to change notification settings - Fork 76
30 lines (30 loc) · 1.38 KB
/
close_old_issues.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
---
name: Close Old Issues
on:
schedule:
- cron: 0 0 * * *
jobs:
close-issues:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Close Old Issues
run: >
open_issues=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}"
\
"https://api.github.com/repos/${{ github.repository }}/issues?state=open" \
| jq -r '.[] | .number')
for issue in $open_issues; do
# Get the last updated timestamp of the issue
last_updated=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/issues/$issue" \
| jq -r '.updated_at')
days_since_update=$(( ( $(date +%s) - $(date -d "$last_updated" +%s) ) / 86400 ))
if [ $days_since_update -gt 20 ]; then # Modify the condition to check if days_since_update is greater than 20
curl -s -X PATCH -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-d '{"state":"closed"}' \
"https://api.github.com/repos/${{ github.repository }}/issues/$issue"
fi
done