-
Notifications
You must be signed in to change notification settings - Fork 2
48 lines (41 loc) · 1.31 KB
/
agent-close-stale-issues.yml
File metadata and controls
48 lines (41 loc) · 1.31 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
name: Agent / Close Stale Issues
on:
schedule:
- cron: "0 9 * * *"
workflow_dispatch:
permissions:
issues: write
concurrency:
group: agent-close-stale-issues-${{ github.repository }}
cancel-in-progress: false
jobs:
close:
if: vars.AGENT_ENABLED != 'false'
runs-on: ${{ fromJson(vars.AGENT_RUNS_ON || '["ubuntu-latest"]') }}
env:
STALE_DAYS: "30"
steps:
- name: Close stale agent issues
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
run: |
set -euo pipefail
cutoff="$(node -e 'const days = Number(process.env.STALE_DAYS || 30); const cutoff = new Date(Date.now() - days * 24 * 60 * 60 * 1000); console.log(cutoff.toISOString().slice(0, 10));')"
gh issue list \
--repo "$REPO" \
--state open \
--label agent \
--search "updated:<$cutoff" \
--limit 1000 \
--json number \
--jq '.[].number' |
while read -r issue; do
if [ -z "$issue" ]; then
continue
fi
gh issue close "$issue" \
--repo "$REPO" \
--reason "not planned" \
--comment "Closing because this agent issue has had no activity for ${STALE_DAYS} days."
done