stale.yml 9.7 KB

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