|
| 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 | + |
| 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. |
0 commit comments