Skip to content

Commit c731830

Browse files
authored
chore: version workflow reusable-stale-prs-issues (#1517)
1 parent 0add6f2 commit c731830

6 files changed

Lines changed: 182 additions & 0 deletions

File tree

.changeset/fresh-queens-buy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"reusable-stale-prs-issues": major
3+
---
4+
5+
Initial versioned release, no changes from latest

.github/workflows/reusable-stale-prs-issues.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# GENERATED FILE - DO NOT EDIT DIRECTLY.
2+
# Source: workflows/reusable-stale-prs-issues/reusable-stale-prs-issues.yml
3+
# Edit the source under workflows/, then regenerate.
4+
15
name: Reusable Stale PRs and Stale Issues
26

37
# This workflow analyzes pull requests and issues to identify and close stale ones that have not had any activity for
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# reusable-stale-prs-issues
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Reusable Stale PRs/Issues
2+
3+
This workflow analyzes pull requests and issues to identify and close stale ones
4+
that have not had any activity for a specified period. It will first add a stale
5+
label to the issue or PR, and if there is still no activity after a specified
6+
duration, it will close the issue or PR. It can also delete the branch if the PR
7+
is closed.
8+
9+
It should be run on a nightly schedule. It's a thin wrapper with defaults set
10+
for https://github.com/actions/stale.
11+
12+
## Usage
13+
14+
```yaml
15+
name: Manage stale Issues and PRs
16+
17+
on:
18+
schedule:
19+
- cron: "0 0 * * *" # Will be triggered every day at midnight UTC
20+
jobs:
21+
permissions:
22+
actions: write
23+
contents: write
24+
issues: write
25+
pull-requests: write
26+
stale-prs:
27+
uses: smartcontractkit/.github/.github/workflows/reusable-stale-prs-issues.yml@<ref>
28+
with:
29+
days-before-pr-stale: 30 # Optional, default value is "30"
30+
secrets:
31+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "reusable-stale-prs-issues",
3+
"version": "0.0.0",
4+
"description": "",
5+
"private": true,
6+
"scripts": {},
7+
"keywords": [],
8+
"author": "@smartcontractkit",
9+
"license": "MIT",
10+
"packageManager": "pnpm@10.29.3"
11+
}
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name: Reusable Stale PRs and Stale Issues
2+
3+
# This workflow analyzes pull requests and issues to identify and close stale ones that have not had any activity for
4+
# a specified period. It will first add a stale label to the issue or PR, and if there is still no activity
5+
# after a specified duration, it will close the issue or PR. It can also delete the branch if the PR is closed.
6+
# It should be run on a nightly schedule. It's a thin wrapper with defaults set for https://github.com/actions/stale.
7+
#
8+
# Usage:
9+
#
10+
# name: Manage stale Issues and PRs
11+
#
12+
# on:
13+
# schedule:
14+
# - cron: "0 0 * * *" # Will be triggered every day at midnight UTC
15+
# jobs:
16+
# permissions:
17+
# actions: write
18+
# contents: write
19+
# issues: write
20+
# pull-requests: write
21+
# stale-prs:
22+
# uses: smartcontractkit/.github/.github/workflows/reusable-stale-prs-issues.yml@<ref>
23+
# with:
24+
# days-before-pr-stale: 30 # Optional, default value is "30"
25+
# secrets:
26+
# GH_TOKEN: $\{{ secrets.GITHUB_TOKEN }} # Remove the \ char to unescape.
27+
28+
on:
29+
workflow_call:
30+
# See: https://github.com/actions/stale?tab=readme-ov-file#list-of-input-options for inputs.
31+
inputs:
32+
close-pr-message:
33+
description: |
34+
The message to post on the pull request when closing it.
35+
If none provided, will not comment when closing a pull requests.
36+
37+
We default to one within the action if this is not provided.
38+
required: false
39+
type: string
40+
delete-branch:
41+
description: "Delete the branch if the PR is closed"
42+
required: false
43+
type: boolean
44+
default: true
45+
days-before-issue-close:
46+
description: "Duration after which a stale issue will be closed"
47+
required: false
48+
type: string
49+
default: "" # unset
50+
days-before-issue-stale:
51+
description: "Duration after which an issue is considered stale"
52+
required: false
53+
type: string
54+
default: "-1" # disables marking issues as stale automatically
55+
days-before-pr-close:
56+
description: "Duration after which a stale PR will be closed"
57+
required: false
58+
type: string
59+
default: "7"
60+
days-before-pr-stale:
61+
description: "Duration after which a PR is considered stale"
62+
required: false
63+
type: string
64+
default: "30" # days
65+
exempt-all-pr-assignees:
66+
description: "Exempt all PRs with assignees from being considered stale"
67+
required: false
68+
type: boolean
69+
default: true
70+
exempt-draft-pr:
71+
description: "Exempt all draft PRs from being considered stale"
72+
required: false
73+
type: boolean
74+
default: false
75+
operations-per-run:
76+
description: |
77+
The maximum number of operations per run, used to control rate
78+
limiting (GitHub API CRUD related).
79+
required: false
80+
type: string
81+
default: "30"
82+
stale-pr-message:
83+
description: |
84+
The message to post on the pull request when tagging it. If none
85+
provided, will not mark pull requests stale.
86+
87+
We default to one within the action if this is not provided.
88+
required: false
89+
type: string
90+
secrets:
91+
GH_TOKEN:
92+
description: "GitHub token for authentication"
93+
required: true
94+
95+
permissions: {}
96+
97+
jobs:
98+
stale:
99+
runs-on: ubuntu-latest
100+
# See: https://github.com/actions/stale?tab=readme-ov-file#recommended-permissions
101+
permissions:
102+
actions: write
103+
contents: write # only for delete-branch option
104+
issues: write
105+
pull-requests: write
106+
107+
steps:
108+
- uses: actions/stale@v10
109+
env:
110+
CLOSE_PR_MESSAGE: |
111+
This PR has been automatically closed because it had been stale for > ${{ inputs.days-before-pr-stale }} days.
112+
If you wish to continue working on this PR, please reopen it to make any necessary changes.
113+
STALE_PR_MESSAGE: |
114+
This PR is stale because it has been open ${{ inputs.days-before-pr-stale }} days with no activity.
115+
Remove the `stale` label, comment, or update this PR to prevent this PR from being closed in ${{ inputs.days-before-pr-close }} days.
116+
with:
117+
repo-token: ${{ secrets.GH_TOKEN }}
118+
close-pr-message: ${{ inputs.close-pr-message || env.CLOSE_PR_MESSAGE }}
119+
days-before-issue-close: ${{ inputs.days-before-issue-close }}
120+
days-before-issue-stale: ${{ inputs.days-before-issue-stale }}
121+
days-before-pr-close: ${{ inputs.days-before-pr-close }}
122+
days-before-pr-stale: ${{ inputs.days-before-pr-stale }}
123+
delete-branch: ${{ inputs.delete-branch }}
124+
exempt-all-pr-assignees: ${{ inputs.exempt-all-pr-assignees }}
125+
exempt-draft-pr: ${{ inputs.exempt-draft-pr }}
126+
# Comma separated list of labels that exempt issues from being considered stale.
127+
exempt-pr-labels: "stale-exempt"
128+
operations-per-run: ${{ inputs.operations-per-run }}
129+
stale-pr-message: ${{ inputs.stale-pr-message || env.STALE_PR_MESSAGE }}

0 commit comments

Comments
 (0)