-
Notifications
You must be signed in to change notification settings - Fork 1
52 lines (49 loc) · 1.54 KB
/
close_old_issues.yaml
File metadata and controls
52 lines (49 loc) · 1.54 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
49
50
51
52
name: Close old issues
on:
workflow_dispatch:
schedule:
- cron: 40 17 */1 * *
permissions:
contents: read
jobs:
close-old-issues:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: List open issues
id: list-issues
uses: actions-cool/issues-helper@v3
with:
actions: find-issues
token: ${{ secrets.GITHUB_TOKEN }}
issue-state: open
exclude-labels: immortal
- name: Close issues with merged PRs
run: |
set -euo pipefail
while read -r line; do
issue=$(jq '.number' -r <<<"$line")
title=$(jq '.title' -r <<<"$line")
pr=$(sed -E 's/.*#([[:digit:]]+).*/\1/g' <<<"$title")
re='^[0-9]+$'
if ! [[ "$pr" =~ $re ]]; then
continue;
fi
status=$(
GH_TOKEN="${GH_TOKEN_PUBLIC}" gh --repo python/mypy pr view "$pr" --json state | jq '.state' -r \
|| echo "unknown"
)
if [[ $status = "MERGED" ]]; then
gh issue close "$issue" --reason completed
elif [[ $status = "unknown" ]]; then
gh issue close "$issue" --reason "not planned"
fi
done < <(jq -c '.[]' <<<"$ISSUES")
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN_PUBLIC: ${{ secrets.CUSTOM_GITHUB_PAT }}
ISSUES: ${{ steps.list-issues.outputs.issues }}