Skip to content

Commit 5e295a9

Browse files
Merge pull request #19691 from cevich/lock_closed_issues
[skip-ci] Lock closed issues and PRs
2 parents 260adf5 + f0e8e79 commit 5e295a9

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

.github/workflows/discussion_lock.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
3+
# Format ref: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
4+
5+
name: "Lock closed Issue/PR discussions"
6+
7+
on:
8+
schedule:
9+
- cron: '0 0 * * *'
10+
# Allow re-use of this workflow by other repositories
11+
# Ref: https://docs.github.com/en/actions/using-workflows/reusing-workflows
12+
workflow_call:
13+
secrets:
14+
ACTION_MAIL_SERVER:
15+
required: true
16+
ACTION_MAIL_USERNAME:
17+
required: true
18+
ACTION_MAIL_PASSWORD:
19+
required: true
20+
ACTION_MAIL_SENDER:
21+
required: true
22+
# Debug: Allow triggering job manually in github-actions WebUI
23+
workflow_dispatch: {}
24+
25+
permissions:
26+
contents: read
27+
28+
concurrency:
29+
group: lock
30+
31+
env:
32+
# Number of days befor a closed issue/PR is be comment-locked.
33+
# Note: dessant/lock-threads will only process a max. of
34+
# 50 issues/PRs at a time.
35+
CLOSED_DAYS: 1825
36+
# Pre-created issue/PR label to add (preferrably a bright color).
37+
# This is intended to direct a would-be commenter's actions.
38+
LOCKED_LABEL: 'locked - please file new issue/PR'
39+
40+
jobs:
41+
closed_issue_discussion_lock:
42+
name: "Lock closed Issue/PR discussions"
43+
runs-on: ubuntu-latest
44+
permissions:
45+
issues: write
46+
pull-requests: write
47+
steps:
48+
# Ref: https://github.com/dessant/lock-threads#usage
49+
- uses: dessant/lock-threads@v4
50+
with:
51+
issue-inactive-days: '${{env.CLOSED_DAYS}}'
52+
pr-inactive-days: '${{env.CLOSED_DAYS}}'
53+
add-issue-labels: '${{env.LOCKED_LABEL}}'
54+
add-pr-labels: '${{env.LOCKED_LABEL}}'
55+
pr-lock-reason: 'resolved'
56+
log-output: true
57+
# Test the failure-notification step functions on failure
58+
- run: |
59+
echo "::warning::Initiating job test-failure to prompt a human to verify this is working and some issues/PRs were locked."
60+
false
61+
- if: failure()
62+
name: Send job failure notification e-mail
63+
uses: dawidd6/[email protected]
64+
with:
65+
server_address: ${{secrets.ACTION_MAIL_SERVER}}
66+
server_port: 465
67+
username: ${{secrets.ACTION_MAIL_USERNAME}}
68+
password: ${{secrets.ACTION_MAIL_PASSWORD}}
69+
subject: Github workflow error on ${{github.repository}}
70+
71+
from: ${{secrets.ACTION_MAIL_SENDER}}
72+
body: |
73+
Job test-failed - https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
74+
75+
Please verify some issues/PRs were locked, then revert the commit which added this check.

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ to see if someone else has already reported it. If so, feel free to add
2121
your scenario, or additional information, to the discussion. Or simply
2222
"subscribe" to it to be notified when it is updated.
2323

24+
Note: Older closed issues/PRs are automatically locked, if you have a similar
25+
problem please open a new issue instead of commenting.
26+
2427
If you find a new issue with the project we'd love to hear about it! The most
2528
important aspect of a bug report is that it includes enough information for
2629
us to reproduce it. To make this easier, there are three types of issue

0 commit comments

Comments
 (0)