1
- name : Close Old Issues
2
- on :
3
- schedule :
4
- - cron : " 0 0 * * *"
5
-
6
- jobs :
7
- close-issues :
8
- runs-on : ubuntu-latest
9
-
10
- steps :
11
- - name : Checkout Repository
12
- uses : actions/checkout@v4
13
-
14
- - name : Close Old Issues
15
- run : |
16
- open_issues=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
17
- "https://api.github.com/repos/${{ github.repository }}/issues?state=open" \
18
- | jq -r '.[] | .number')
19
- for issue in $open_issues; do
20
- # Get the last updated timestamp of the issue
21
- last_updated=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
22
- "https://api.github.com/repos/${{ github.repository }}/issues/$issue" \
23
- | jq -r '.updated_at')
24
- days_since_update=$(( ( $(date +%s) - $(date -d "$last_updated" +%s) ) / 86400 ))
25
- if [ $days_since_update -gt 30 ]; then
26
- curl -s -X PATCH -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
27
- -H "Accept: application/vnd.github.v3+json" \
28
- -d '{"state":"closed"}' \
29
- "https://api.github.com/repos/${{ github.repository }}/issues/$issue"
30
-
31
- # Add a comment explaining when the issue will be closed
32
- curl -s -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
33
- -H "Accept: application/vnd.github.v3+json" \
34
- -d '{"body":"This issue has been automatically closed because it has been inactive for more than 30 days. If you believe this is still relevant, feel free to reopen it or create a new one. Thank you!"}' \
35
- "https://api.github.com/repos/${{ github.repository }}/issues/$issue/comments"
36
- fi
1
+ name : Close Old Issues
2
+ on :
3
+ schedule :
4
+ - cron : " 0 0 * * *"
5
+
6
+ jobs :
7
+ close-issues :
8
+ runs-on : ubuntu-latest
9
+
10
+ steps :
11
+ - name : Checkout Repository
12
+ uses : actions/checkout@v4
13
+
14
+ - name : Close Old Issues
15
+ run : |
16
+ open_issues=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
17
+ "https://api.github.com/repos/${{ github.repository }}/issues?state=open" \
18
+ | jq -r '.[] | .number')
19
+ for issue in $open_issues; do
20
+ # Get the last updated timestamp of the issue
21
+ last_updated=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
22
+ "https://api.github.com/repos/${{ github.repository }}/issues/$issue" \
23
+ | jq -r '.updated_at')
24
+ days_since_update=$(( ( $(date +%s) - $(date -d "$last_updated" +%s) ) / 86400 ))
25
+ if [ $days_since_update -gt 30 ]; then
26
+ curl -s -X PATCH -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
27
+ -H "Accept: application/vnd.github.v3+json" \
28
+ -d '{"state":"closed"}' \
29
+ "https://api.github.com/repos/${{ github.repository }}/issues/$issue"
30
+
31
+ # Add a comment explaining when the issue will be closed
32
+ curl -s -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
33
+ -H "Accept: application/vnd.github.v3+json" \
34
+ -d '{"body":"This issue has been automatically closed because it has been inactive for more than 30 days. If you believe this is still relevant, feel free to reopen it or create a new one. Thank you!"}' \
35
+ "https://api.github.com/repos/${{ github.repository }}/issues/$issue/comments"
36
+ fi
37
37
done
0 commit comments