|
1 |
| -name: Stale and close inactive issues/PRs |
| 1 | +name: Stale handler |
2 | 2 |
|
3 | 3 | on:
|
4 |
| - schedule: |
5 |
| - - cron: "0 0,6,12,18 * * *" # every 6 hours at o'clock |
6 |
| - workflow_dispatch: # or manually |
| 4 | + push: # when push this files to branches.... |
| 5 | + branches: |
| 6 | + - 'main' |
| 7 | + - 'gh-actions/test' |
| 8 | + paths: |
| 9 | + - '.github/workflows/stale.yml' # - this workflow |
| 10 | + workflow_dispatch: # manually |
| 11 | + inputs: |
| 12 | + debug-only: |
| 13 | + type: boolean |
| 14 | + description: 'If enabled, debug mode is on and then API calls that can alter your issues will not happen' |
| 15 | + required: true |
| 16 | + default: true |
| 17 | + schedule: # or |
| 18 | + - cron: "0 0,6,12,18 * * *" # every 6 hours at o'clock |
7 | 19 |
|
8 | 20 | permissions:
|
| 21 | + # no checkout/branching needed |
9 | 22 | contents: none
|
10 |
| - issues: read |
11 |
| - pull-requests: read |
12 | 23 |
|
13 |
| -# This allows a subsequently queued workflow run to interrupt previous runs |
| 24 | +# This allows a subsequently queued workflow run to interrupt/wait for previous runs |
14 | 25 | concurrency:
|
15 |
| - group: '${{ github.workflow }} @ ${{ github.run_id }}' |
16 |
| - cancel-in-progress: true |
| 26 | + group: '${{ github.workflow }}' |
| 27 | + cancel-in-progress: false # true: interrupt, false = wait for |
17 | 28 |
|
18 | 29 | jobs:
|
19 |
| - |
20 |
| - process-issues: |
21 |
| - name: Process Issues |
22 |
| - # This allows a subsequently queued workflow run to wait for previous runs completion |
23 |
| - concurrency: |
24 |
| - group: '${{ github.workflow }} @ ${{ github.run_id }} :: issues' |
25 |
| - cancel-in-progress: false |
26 |
| - # export variables used by reporter job |
| 30 | + stale: |
| 31 | + name: Staler job |
| 32 | + runs-on: ubuntu-latest |
27 | 33 | outputs:
|
28 |
| - staled-issues: ${{ steps.stale.outputs.staled-issues-prs }} |
29 |
| - closed-issues: ${{ steps.stale.outputs.closed-issues-prs }} |
30 |
| - # enable write access rights to allow comment and labeling by bot |
| 34 | + # "XXX-len": the length of the "XXX" output object |
| 35 | + staled-issues: ${{ steps.set-staled.outputs.issues }} |
| 36 | + staled-issues-len: ${{ steps.set-staled.outputs.issues-len }} |
| 37 | + staled-prs: ${{ steps.set-staled.outputs.prs }} |
| 38 | + staled-prs-len: ${{ steps.set-staled.outputs.prs-len }} |
| 39 | + closed-issues: ${{ steps.set-closed.outputs.issues }} |
| 40 | + closed-issues-len: ${{ steps.set-closed.outputs.issues-len }} |
| 41 | + closed-prs: ${{ steps.set-closed.outputs.prs }} |
| 42 | + closed-prs-len: ${{ steps.set-closed.outputs.prs-len }} |
| 43 | + # enable write access rights to allow bot comments and labeling |
31 | 44 | permissions:
|
32 | 45 | issues: write
|
33 |
| - runs-on: ubuntu-latest |
| 46 | + pull-requests: write |
34 | 47 | steps:
|
35 |
| - - uses: actions/stale@v5 |
36 |
| - id: staler |
| 48 | + - name: Stale issues |
| 49 | + uses: actions/stale@v5 |
| 50 | + id: stale-issues |
37 | 51 | with:
|
| 52 | + debug-only: ${{ github.event.inputs.debug-only == 'true' }} |
38 | 53 | operations-per-run: 30
|
39 |
| - days-before-issue-stale: 60 |
40 |
| - days-before-issue-close: 30 |
| 54 | + days-before-stale: 60 |
| 55 | + days-before-close: 30 |
| 56 | + ignore-updates: false |
| 57 | + remove-stale-when-updated: true |
41 | 58 | stale-issue-label: "stale"
|
42 | 59 | close-issue-label: "stale: closed"
|
43 | 60 | stale-issue-message: |
|
44 |
| - This issue has been automatically marked as stale because it has not had activity during the last 60 days. |
| 61 | + This issue has been automatically marked as stale because it has not had recent activity during last 60 days :sleeping: |
45 | 62 |
|
46 |
| - It will be closed if no further activity occurs on the next 30 days. |
| 63 | + It will be closed in 30 days if no further activity occurs. To unstale this issue, remove stale label or add a comment with a detailed explanation. |
47 | 64 |
|
48 |
| - Thank you for your contributions. |
| 65 | + There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. |
| 66 | +
|
| 67 | + Thank you for your patience :heart: |
49 | 68 | close-issue-message: |
|
50 | 69 | This issue has been automatically closed because it has been inactive during the last 30 days since being marked as stale.
|
51 | 70 |
|
52 |
| - Anyway, thank you for your contributions. |
53 |
| - remove-issue-stale-when-updated: true |
| 71 | + As author or maintainer, it can always be reopened if you see that carry on been useful. |
| 72 | +
|
| 73 | + Anyway, thank you for your interest in contribute :heart: |
| 74 | + close-issue-reason: not_planned |
54 | 75 | exempt-issue-labels: "blocked,must,should,keep,:busts_in_silhouette: discussion,:eyes: Needs Review,:pushpin: pinned"
|
| 76 | + # disable PR processing at all (this step is for treat issues) |
55 | 77 | days-before-pr-stale: -1
|
56 | 78 | days-before-pr-close: -1
|
| 79 | + ignore-pr-updates: true |
| 80 | + remove-pr-stale-when-updated: false |
| 81 | + stale-pr-label: " " |
57 | 82 |
|
58 |
| - - name: Set outputs |
59 |
| - ## Removing private properties from each JSON object. |
60 |
| - ## TODO: Remove this ugly fix for actions/stale#806 |
61 |
| - id: stale |
62 |
| - run: | |
63 |
| - echo $STALED \ |
64 |
| - | jq --compact-output --raw-output 'del(.[] | .[to_entries[] | .key | select(startswith("_"))])' \ |
65 |
| - | sed -e 's/^/::set-output name=staled-issues-prs::/' |
66 |
| - echo $CLOSED \ |
67 |
| - | jq --compact-output --raw-output 'del(.[] | .[to_entries[] | .key | select(startswith("_"))])' \ |
68 |
| - | sed -e 's/^/::set-output name=closed-issues-prs::/' |
69 |
| - env: |
70 |
| - STALED: ${{ steps.staler.outputs.staled-issues-prs }} |
71 |
| - CLOSED: ${{ steps.staler.outputs.closed-issues-prs }} |
| 83 | + - name: Print outputs for issues |
| 84 | + run: echo ${{ join(steps.stale-issues.outputs.*, ',') }} |
72 | 85 |
|
73 |
| - |
74 |
| - process-prs: |
75 |
| - name: Process Pull Requests |
76 |
| - # This allows a subsequently queued workflow run to wait for previous runs completion |
77 |
| - concurrency: |
78 |
| - group: '${{ github.workflow }} @ ${{ github.run_id }} :: PRs' |
79 |
| - cancel-in-progress: false |
80 |
| - # export variables used by reporter job |
81 |
| - outputs: |
82 |
| - staled-prs: ${{ steps.stale.outputs.staled-issues-prs }} |
83 |
| - closed-prs: ${{ steps.stale.outputs.closed-issues-prs }} |
84 |
| - # enable write access rights to allow comment and labeling by bot |
85 |
| - permissions: |
86 |
| - pull-requests: write |
87 |
| - runs-on: ubuntu-latest |
88 |
| - steps: |
89 |
| - - uses: actions/stale@v5 |
90 |
| - id: staler |
| 86 | + - name: Stale Pull Requests |
| 87 | + uses: actions/stale@v5 |
| 88 | + id: stale-prs |
91 | 89 | with:
|
| 90 | + debug-only: ${{ github.event.inputs.debug-only == 'true' }} |
92 | 91 | operations-per-run: 30
|
93 |
| - days-before-pr-stale: 60 |
94 |
| - days-before-pr-close: 30 |
| 92 | + days-before-stale: 60 |
| 93 | + days-before-close: 30 |
| 94 | + ignore-updates: false |
| 95 | + remove-stale-when-updated: true |
95 | 96 | stale-pr-label: "stale"
|
96 | 97 | close-pr-label: "stale: closed"
|
97 | 98 | stale-pr-message: |
|
98 |
| - This pull request has been automatically marked as stale because it has not had activity during the last 60 days. |
| 99 | + This Pull Request has been automatically marked as stale because it has not had recent activity during last 60 days :sleeping: |
| 100 | +
|
| 101 | + It will be closed in 30 days if no further activity occurs. To unstale this PR, draft it, remove stale label, comment with a detailed explanation or push more commits. |
99 | 102 |
|
100 |
| - It will be closed if no further activity occurs on the next 30 days. |
| 103 | + There can be many reasons why some specific PR has no activity. The most probable cause is lack of time, not lack of interest. |
101 | 104 |
|
102 |
| - Thank you for your contributions. |
| 105 | + Thank you for your patience :heart: |
103 | 106 | close-pr-message: |
|
104 |
| - This pull request has been automatically closed because it has been inactive during the last 30 days since being marked as stale. |
| 107 | + This Pull Request has been automatically closed because it has been inactive during the last 30 days since being marked as stale. |
105 | 108 |
|
106 |
| - Anyway, thank you for your contributions. |
107 |
| - remove-pr-stale-when-updated: true |
108 |
| - exempt-pr-labels: "blocked,must,should,keep,:busts_in_silhouette: discussion,:eyes: Needs Review" |
| 109 | + As author or maintainer, it can always be reopened if you see that carry on been useful. |
| 110 | +
|
| 111 | + Anyway, thank you for your interest in contribute :heart: |
109 | 112 | exempt-draft-pr: true
|
| 113 | + exempt-pr-labels: "blocked,must,should,keep,:busts_in_silhouette: discussion,:eyes: Needs Review" |
| 114 | + delete-branch: false # if true, job needs permissions "contents: write" |
| 115 | + # disable issues processing at all (this step is for treat PRs) |
110 | 116 | days-before-issue-stale: -1
|
111 | 117 | days-before-issue-close: -1
|
| 118 | + ignore-issue-updates: true |
| 119 | + remove-issue-stale-when-updated: false |
| 120 | + stale-issue-label: " " |
| 121 | + |
| 122 | + - name: Print outputs for PRs |
| 123 | + run: echo ${{ join(steps.stale-prs.outputs.*, ',') }} |
112 | 124 |
|
113 |
| - - name: Set outputs |
114 |
| - ## Removing private properties from each JSON object. |
115 |
| - ## TODO: Remove this ugly fix for actions/stale#806 |
116 |
| - id: stale |
| 125 | + ## Removing private properties from each JSON object and compute array length |
| 126 | + ## TODO: Delete these set-* workarounds when resolve actions/stale#806 ? |
| 127 | + - name: Set staled |
| 128 | + id: set-staled |
117 | 129 | run: |
|
118 |
| - echo $STALED \ |
| 130 | + echo $INPUT_ISSUES \ |
119 | 131 | | jq --compact-output --raw-output 'del(.[] | .[to_entries[] | .key | select(startswith("_"))])' \
|
120 |
| - | sed -e 's/^/::set-output name=staled-issues-prs::/' |
121 |
| - echo $CLOSED \ |
| 132 | + | sed -e 's/^/::set-output name=issues::/' |
| 133 | + echo $INPUT_ISSUES \ |
| 134 | + | jq --raw-output '. | length' \ |
| 135 | + | sed -e 's/^/::set-output name=issues-len::/' |
| 136 | +
|
| 137 | + echo $INPUT_PRS \ |
122 | 138 | | jq --compact-output --raw-output 'del(.[] | .[to_entries[] | .key | select(startswith("_"))])' \
|
123 |
| - | sed -e 's/^/::set-output name=closed-issues-prs::/' |
| 139 | + | sed -e 's/^/::set-output name=prs::/' |
| 140 | + echo $INPUT_PRS \ |
| 141 | + | jq --raw-output '. | length' \ |
| 142 | + | sed -e 's/^/::set-output name=prs-len::/' |
124 | 143 | env:
|
125 |
| - STALED: ${{ steps.staler.outputs.staled-issues-prs }} |
126 |
| - CLOSED: ${{ steps.staler.outputs.closed-issues-prs }} |
| 144 | + INPUT_ISSUES: ${{ steps.stale-issues.outputs.staled-issues-prs }} |
| 145 | + INPUT_PRS: ${{ steps.stale-prs.outputs.staled-issues-prs }} |
| 146 | + - name: Set closed |
| 147 | + id: set-closed |
| 148 | + run: | |
| 149 | + echo $INPUT_ISSUES \ |
| 150 | + | jq --compact-output --raw-output 'del(.[] | .[to_entries[] | .key | select(startswith("_"))])' \ |
| 151 | + | sed -e 's/^/::set-output name=issues::/' |
| 152 | + echo $INPUT_ISSUES \ |
| 153 | + | jq --raw-output '. | length' \ |
| 154 | + | sed -e 's/^/::set-output name=issues-len::/' |
127 | 155 |
|
| 156 | + echo $INPUT_PRS \ |
| 157 | + | jq --compact-output --raw-output 'del(.[] | .[to_entries[] | .key | select(startswith("_"))])' \ |
| 158 | + | sed -e 's/^/::set-output name=prs::/' |
| 159 | + echo $INPUT_PRS \ |
| 160 | + | jq --raw-output '. | length' \ |
| 161 | + | sed -e 's/^/::set-output name=prs-len::/' |
| 162 | + env: |
| 163 | + INPUT_ISSUES: ${{ steps.stale-issues.outputs.closed-issues-prs }} |
| 164 | + INPUT_PRS: ${{ steps.stale-prs.outputs.closed-issues-prs }} |
128 | 165 |
|
129 |
| - reporter: |
130 |
| - name: GitHub reporter |
131 |
| - needs: [process-issues, process-prs] |
132 |
| - runs-on: ubuntu-latest |
133 |
| - steps: |
134 |
| - - run: | |
| 166 | + - name: Write job summary |
| 167 | + run: | |
135 | 168 | echo "### Staled issues" \
|
136 | 169 | >> $GITHUB_STEP_SUMMARY
|
| 170 | + # render json array to a Markdown table with an optional "No records" message if empty |
137 | 171 | echo "$STALED_ISSUES" \
|
138 |
| - | jq --raw-output 'map("* [#\(.number)](\(env.GITHUB_ISSUES_URL)/\(.number)): \(.title)") | join("\n")' \ |
| 172 | + | jq --raw-output 'map("| [#\(.number)](\(env.GITHUB_ISSUES_URL)/\(.number)) | \(.title) |") | join("\n") | if (. == "") then "\nNo records.\n" else "\n| | Title |\n|---:|:------|\n\(.)\n" end' \ |
139 | 173 | >> $GITHUB_STEP_SUMMARY
|
140 | 174 |
|
141 | 175 | echo "### Staled pull requests" \
|
142 | 176 | >> $GITHUB_STEP_SUMMARY
|
| 177 | + # render json array to a Markdown table with an optional "No records" message if empty |
143 | 178 | echo "$STALED_PRS" \
|
144 |
| - | jq --raw-output 'map("* [#\(.number)](\(env.GITHUB_PULL_URL)/\(.number)): \(.title)") | join("\n")' \ |
| 179 | + | jq --raw-output 'map("| [#\(.number)](\(env.GITHUB_PULL_URL)/\(.number)) | \(.title) |") | join("\n") | if (. == "") then "\nNo records.\n" else "\n| | Title |\n|---:|:------|\n\(.)\n" end' \ |
145 | 180 | >> $GITHUB_STEP_SUMMARY
|
146 | 181 |
|
147 | 182 | echo "### Closed issues" \
|
148 | 183 | >> $GITHUB_STEP_SUMMARY
|
| 184 | + # render json array to a Markdown table with an optional "No records" message if empty |
149 | 185 | echo "$CLOSED_ISSUES" \
|
150 |
| - | jq --raw-output 'map("* [#\(.number)](\(env.GITHUB_ISSUES_URL)/\(.number)): \(.title)") | join("\n")' \ |
| 186 | + | jq --raw-output 'map("| [#\(.number)](\(env.GITHUB_ISSUES_URL)/\(.number)) | \(.title) |") | join("\n") | if (. == "") then "\nNo records.\n" else "\n| | Title |\n|---:|:------|\n\(.)\n" end' \ |
151 | 187 | >> $GITHUB_STEP_SUMMARY
|
152 | 188 |
|
153 | 189 | echo "### Closed pull requests" \
|
154 | 190 | >> $GITHUB_STEP_SUMMARY
|
| 191 | + # render json array to a Markdown table with an optional "No records" message if empty |
155 | 192 | echo "$CLOSED_PRS" \
|
156 |
| - | jq --raw-output 'map("* [#\(.number)](\(env.GITHUB_PULL_URL)/\(.number)): \(.title)") | join("\n")' \ |
| 193 | + | jq --raw-output 'map("| [#\(.number)](\(env.GITHUB_PULL_URL)/\(.number)) | \(.title) |") | join("\n") | if (. == "") then "\nNo records.\n" else "\n| | Title |\n|---:|:------|\n\(.)\n" end' \ |
157 | 194 | >> $GITHUB_STEP_SUMMARY
|
158 | 195 | env:
|
159 |
| - GITHUB_REPO_URL: ${{ format('{0}/{1}', github.server_url, github.repository) }} |
160 | 196 | GITHUB_ISSUES_URL: ${{ format('{0}/{1}/issues', github.server_url, github.repository) }}
|
161 | 197 | GITHUB_PULL_URL: ${{ format('{0}/{1}/pull', github.server_url, github.repository) }}
|
162 |
| - STALED_ISSUES: ${{ needs.process-issues.outputs.staled-issues }} |
163 |
| - CLOSED_ISSUES: ${{ needs.process-issues.outputs.closed-issues }} |
164 |
| - STALED_PRS: ${{ needs.process-prs.outputs.staled-prs }} |
165 |
| - CLOSED_PRS: ${{ needs.process-prs.outputs.closed-prs }} |
| 198 | + STALED_ISSUES: ${{ steps.set-staled.outputs.issues }} |
| 199 | + CLOSED_ISSUES: ${{ steps.set-closed.outputs.issues }} |
| 200 | + STALED_PRS: ${{ steps.set-staled.outputs.prs }} |
| 201 | + CLOSED_PRS: ${{ steps.set-closed.outputs.prs }} |
0 commit comments