|
1 | | -# This workflow add "stale" label to issues that have "stat:awaiting-response" for more than 60 days meaning that since we don't have enough information we may potentially close such issue |
| 1 | +# This workflow utilises an existing implementation (https://github.com/actions/stale) that performs the following actions: |
| 2 | +# 1) Adds "stale" label to issues that have "stat:awaiting-response" for more than 30 days meaning that since we don't have enough information we may potentially close such issue |
| 3 | +# 2) Closes issues that have been marked as "stale" for more than 30 days |
2 | 4 |
|
3 | | -name: Mark Stale Issues |
| 5 | +# This affects only Issues but at some point we may also consider rules for PRs |
| 6 | + |
| 7 | +name: Mark and Close Stale Issues |
4 | 8 |
|
5 | 9 | on: |
6 | 10 | workflow_dispatch: |
7 | 11 | schedule: |
8 | 12 | - cron: '0 0 * * *' # Runs daily at midnight |
9 | 13 |
|
10 | | -env: |
11 | | - AWAITING-RESPONSE_LABEL: stat:awaiting-response |
12 | | - STALE_LABEL: stale |
13 | | - DAYS_BEFORE_STALE: 60 # 2 months |
14 | | - |
15 | 14 | jobs: |
16 | | - mark_stale: |
17 | | - name: Check and Mark Stale Issues |
18 | | - if: ${{ !github.event.issue.pull_request }} && ${{ github.event.issue.state == 'open' }} |
| 15 | + stale: |
19 | 16 | runs-on: ubuntu-latest |
20 | 17 | permissions: |
21 | 18 | issues: write |
22 | | - |
| 19 | + |
23 | 20 | steps: |
24 | | - - name: Get Issues with Awaiting Response |
25 | | - id: get_issues |
26 | | - run: | |
27 | | - # Get all open issues with awaiting-response label |
28 | | - ISSUES=$(gh issue list --label "${{ env.AWAITING-RESPONSE_LABEL }}" --json number,labels,updatedAt --jq '.[]') |
29 | | - |
30 | | - echo "ISSUES=$ISSUES" >> $GITHUB_ENV |
31 | | -
|
32 | | - - name: Process Issues |
33 | | - run: | |
34 | | - current_time=$(date +%s) |
35 | | - |
36 | | - echo "$ISSUES" | while read -r issue; do |
37 | | - # Extract issue details |
38 | | - number=$(echo "$issue" | jq -r .number) |
39 | | - updated_at=$(echo "$issue" | jq -r .updatedAt) |
40 | | - has_stale=$(echo "$issue" | jq -r '.labels[].name | select(. == "stale")' || echo "") |
41 | | - |
42 | | - # Convert updated_at to timestamp |
43 | | - updated_time=$(date -d "$updated_at" +%s) |
44 | | - |
45 | | - # Calculate days difference |
46 | | - days_diff=$(( (current_time - updated_time) / 86400 )) |
47 | | - |
48 | | - # Check if issue should be marked stale |
49 | | - if [[ $days_diff -ge ${{ env.DAYS_BEFORE_STALE }} && -z "$has_stale" ]]; then |
50 | | - echo "Marking issue #$number as stale" |
51 | | - gh issue edit "$number" --add-label "${{ env.STALE_LABEL }}" \ |
52 | | - --body-file <( |
53 | | - echo "This issue has been automatically marked as stale because it has been awaiting response for over 2 months without any activity." |
54 | | - echo "" |
55 | | - echo "Please update the issue with any new information or it may be closed in the future." |
56 | | - ) |
57 | | - fi |
58 | | - done |
59 | | - env: |
60 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
61 | | - GH_REPO: ${{ github.repository }} |
| 21 | + - uses: actions/stale@v9 |
| 22 | + with: |
| 23 | + # Only mark issues (not PRs) as stale |
| 24 | + only-issue-labels: 'stat:awaiting-response' |
| 25 | + days-before-stale: 30 |
| 26 | + days-before-close: 30 |
| 27 | + stale-issue-label: 'Stale' |
| 28 | + stale-issue-message: > |
| 29 | + This issue has been automatically marked as stale because it has been awaiting |
| 30 | + response for over 30 days without any activity. |
62 | 31 |
|
| 32 | + Please update the issue with any new information or it may be closed in 30 days. |
| 33 | + close-issue-message: > |
| 34 | + This issue has been automatically closed because it has been stale for 30 days |
| 35 | + without any activity. Feel free to reopen if you have new information to add. |
| 36 | + # Prevent the action from marking/closing PRs |
| 37 | + days-before-pr-stale: -1 |
| 38 | + days-before-pr-close: -1 |
0 commit comments