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