Skip to content

Commit 4af098f

Browse files
committed
re-configure stale workflow for testing
1 parent 7e84d45 commit 4af098f

File tree

2 files changed

+229
-19
lines changed

2 files changed

+229
-19
lines changed

Diff for: .github/workflows/stale-new.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: 'Close Stale PRs'
2+
on:
3+
# Disable schedule for test purposes, enable once verified
4+
# schedule:
5+
# - cron: '0 0 * * *' # Run every day at midnight
6+
workflow_dispatch:
7+
inputs:
8+
debug-only:
9+
type: boolean
10+
description: "Does a dry-run when enabled. No PR's will be altered"
11+
required: true
12+
default: true
13+
14+
permissions:
15+
pull-requests: write
16+
17+
jobs:
18+
stale:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/stale@v9
22+
with:
23+
days-before-issue-stale: -1 # Don't mark issues as stale
24+
days-before-issue-close: -1 # Don't close issues
25+
stale-pr-message: |
26+
'This Pull Request has been automatically marked as stale because it has not had recent activity during last 60 days :sleeping:
27+
28+
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.
29+
30+
There can be many reasons why some specific PR has no activity. The most probable cause is lack of time, not lack of interest.
31+
32+
Thank you for your patience :heart:'
33+
close-pr-message: |
34+
This Pull Request has been automatically closed because it has been inactive during the last 30 days since being marked as stale.
35+
36+
As author or maintainer, it can always be reopened if you see that carry on been useful.
37+
38+
Anyway, thank you for your interest in contribute :heart:
39+
days-before-pr-stale: 60
40+
days-before-pr-close: 30
41+
stale-pr-label: 'stale'
42+
exempt-pr-labels: 'keep' # Don't mark PR's with this label as stale
43+
labels-to-remove-when-unstale: 'stale'
44+
exempt-draft-pr: true
45+
debug-only: ${{ github.event.inputs.debug-only == 'true' }}
46+
enable-statistics: true
47+
# delete-branch: true

Diff for: .github/workflows/stale.yml

+182-19
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,209 @@
1-
name: 'Close Stale PRs'
1+
name: Stale handler
2+
23
on:
3-
schedule:
4-
- cron: '0 0 * * *' # Run every day at midnight
5-
workflow_dispatch:
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
611
inputs:
712
debug-only:
813
type: boolean
9-
description: "Does a dry-run when enabled. No PR's will be altered"
14+
description: 'If enabled, debug mode is on and then API calls that can alter your issues will not happen'
1015
required: true
1116
default: true
17+
schedule: # or
18+
- cron: "0 0 * * *" # once a day at 00:00 o'clock
1219

1320
permissions:
14-
pull-requests: write
21+
# no checkout/branching needed
22+
contents: none
23+
24+
# This allows a subsequently queued workflow run to interrupt/wait for previous runs
25+
concurrency:
26+
group: '${{ github.workflow }}'
27+
cancel-in-progress: false # true: interrupt, false = wait for
1528

1629
jobs:
1730
stale:
31+
name: Staler job
1832
runs-on: ubuntu-latest
33+
outputs:
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
44+
permissions:
45+
issues: write
46+
pull-requests: write
1947
steps:
20-
- uses: actions/stale@v9
48+
- name: Stale issues
49+
uses: actions/stale@v9
50+
id: stale-issues
2151
with:
22-
days-before-issue-stale: -1 # Don't mark issues as stale
23-
days-before-issue-close: -1 # Don't close issues
52+
debug-only: ${{ github.event.inputs.debug-only == 'true' }}
53+
operations-per-run: 30
54+
days-before-stale: 60
55+
days-before-close: 30
56+
ignore-updates: false
57+
remove-stale-when-updated: true
58+
stale-issue-label: "stale"
59+
close-issue-label: "stale: closed"
60+
stale-issue-message: |
61+
This issue has been automatically marked as stale because it has not had recent activity during last 60 days :sleeping:
62+
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.
64+
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:
68+
close-issue-message: |
69+
This issue has been automatically closed because it has been inactive during the last 30 days since being marked as stale.
70+
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
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)
77+
days-before-pr-stale: -1
78+
days-before-pr-close: -1
79+
ignore-pr-updates: true
80+
remove-pr-stale-when-updated: false
81+
stale-pr-label: " "
82+
83+
- name: Print outputs for issues
84+
run: echo ${{ format('{0},{1}', toJSON(steps.stale-issues.outputs.staled-issues-prs), toJSON(steps.stale-issues.outputs.closed-issues-prs)) }}
85+
86+
- name: Stale Pull Requests
87+
uses: actions/stale@v9
88+
id: stale-prs
89+
with:
90+
debug-only: ${{ github.event.inputs.debug-only == 'true' }}
91+
operations-per-run: 30
92+
days-before-stale: 60
93+
days-before-close: 30
94+
ignore-updates: false
95+
remove-stale-when-updated: true
96+
stale-pr-label: "stale"
97+
close-pr-label: "stale: closed"
2498
stale-pr-message: |
25-
'This Pull Request has been automatically marked as stale because it has not had recent activity during last 60 days :sleeping:
99+
This Pull Request has been automatically marked as stale because it has not had recent activity during last 60 days :sleeping:
26100
27101
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.
28102
29103
There can be many reasons why some specific PR has no activity. The most probable cause is lack of time, not lack of interest.
30104
31-
Thank you for your patience :heart:'
105+
Thank you for your patience :heart:
32106
close-pr-message: |
33107
This Pull Request has been automatically closed because it has been inactive during the last 30 days since being marked as stale.
34108
35109
As author or maintainer, it can always be reopened if you see that carry on been useful.
36110
37111
Anyway, thank you for your interest in contribute :heart:
38-
days-before-pr-stale: 60
39-
days-before-pr-close: 30
40-
stale-pr-label: 'stale'
41-
exempt-pr-labels: 'keep' # Don't mark PR's with this label as stale
42-
labels-to-remove-when-unstale: 'stale'
43112
exempt-draft-pr: true
44-
debug-only: ${{ github.event.inputs.debug-only == 'true' }}
45-
enable-statistics: true
46-
# delete-branch: 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)
116+
days-before-issue-stale: -1
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 ${{ format('{0},{1}', toJSON(steps.stale-prs.outputs.staled-issues-prs), toJSON(steps.stale-prs.outputs.closed-issues-prs)) }}
124+
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
129+
run: |
130+
echo $INPUT_ISSUES \
131+
| jq --compact-output --raw-output 'del(.[] | .[to_entries[] | .key | select(startswith("_"))])' \
132+
| sed -e 's/^/issues=/' \
133+
>> $GITHUB_OUTPUT
134+
echo $INPUT_ISSUES \
135+
| jq --raw-output '. | length' \
136+
| sed -e 's/^/issues-len=/' \
137+
>> $GITHUB_OUTPUT
138+
139+
echo $INPUT_PRS \
140+
| jq --compact-output --raw-output 'del(.[] | .[to_entries[] | .key | select(startswith("_"))])' \
141+
| sed -e 's/^/prs=/' \
142+
>> $GITHUB_OUTPUT
143+
echo $INPUT_PRS \
144+
| jq --raw-output '. | length' \
145+
| sed -e 's/^/prs-len=/' \
146+
>> $GITHUB_OUTPUT
147+
env:
148+
INPUT_ISSUES: ${{ steps.stale-issues.outputs.staled-issues-prs }}
149+
INPUT_PRS: ${{ steps.stale-prs.outputs.staled-issues-prs }}
150+
- name: Set closed
151+
id: set-closed
152+
run: |
153+
echo $INPUT_ISSUES \
154+
| jq --compact-output --raw-output 'del(.[] | .[to_entries[] | .key | select(startswith("_"))])' \
155+
| sed -e 's/^/issues=/' \
156+
>> $GITHUB_OUTPUT
157+
echo $INPUT_ISSUES \
158+
| jq --raw-output '. | length' \
159+
| sed -e 's/^/issues-len=/' \
160+
>> $GITHUB_OUTPUT
161+
162+
echo $INPUT_PRS \
163+
| jq --compact-output --raw-output 'del(.[] | .[to_entries[] | .key | select(startswith("_"))])' \
164+
| sed -e 's/^/prs=/' \
165+
>> $GITHUB_OUTPUT
166+
echo $INPUT_PRS \
167+
| jq --raw-output '. | length' \
168+
| sed -e 's/^/prs-len=/' \
169+
>> $GITHUB_OUTPUT
170+
env:
171+
INPUT_ISSUES: ${{ steps.stale-issues.outputs.closed-issues-prs }}
172+
INPUT_PRS: ${{ steps.stale-prs.outputs.closed-issues-prs }}
173+
174+
- name: Write job summary
175+
run: |
176+
echo "### Staled issues" \
177+
>> $GITHUB_STEP_SUMMARY
178+
# render json array to a Markdown table with an optional "No records" message if empty
179+
echo "$STALED_ISSUES" \
180+
| 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' \
181+
>> $GITHUB_STEP_SUMMARY
182+
183+
echo "### Staled pull requests" \
184+
>> $GITHUB_STEP_SUMMARY
185+
# render json array to a Markdown table with an optional "No records" message if empty
186+
echo "$STALED_PRS" \
187+
| 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' \
188+
>> $GITHUB_STEP_SUMMARY
189+
190+
echo "### Closed issues" \
191+
>> $GITHUB_STEP_SUMMARY
192+
# render json array to a Markdown table with an optional "No records" message if empty
193+
echo "$CLOSED_ISSUES" \
194+
| 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' \
195+
>> $GITHUB_STEP_SUMMARY
196+
197+
echo "### Closed pull requests" \
198+
>> $GITHUB_STEP_SUMMARY
199+
# render json array to a Markdown table with an optional "No records" message if empty
200+
echo "$CLOSED_PRS" \
201+
| 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' \
202+
>> $GITHUB_STEP_SUMMARY
203+
env:
204+
GITHUB_ISSUES_URL: ${{ format('{0}/{1}/issues', github.server_url, github.repository) }}
205+
GITHUB_PULL_URL: ${{ format('{0}/{1}/pull', github.server_url, github.repository) }}
206+
STALED_ISSUES: ${{ steps.set-staled.outputs.issues }}
207+
CLOSED_ISSUES: ${{ steps.set-closed.outputs.issues }}
208+
STALED_PRS: ${{ steps.set-staled.outputs.prs }}
209+
CLOSED_PRS: ${{ steps.set-closed.outputs.prs }}

0 commit comments

Comments
 (0)