Locker - Lock stale issues and PRs, unlock reopened ones #750
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Locker - Lock stale issues and PRs, unlock reopened ones | |
| on: | |
| schedule: | |
| - cron: '37 8 * * *' # Once per day, early morning PT | |
| workflow_dispatch: | |
| # Manual triggering through the GitHub UI, API, or CLI | |
| inputs: | |
| daysSinceClose: | |
| required: true | |
| default: "30" | |
| daysSinceUpdate: | |
| required: true | |
| default: "30" | |
| issues: | |
| types: [reopened] | |
| pull_request_target: | |
| types: [reopened] | |
| permissions: | |
| issues: write | |
| pull-requests: write | |
| jobs: | |
| lock: | |
| runs-on: ubuntu-latest | |
| # Only run the locking job for scheduled runs and manual dispatch, not for reopened events | |
| if: ${{ github.repository_owner == 'dotnet' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }} | |
| steps: | |
| - name: Checkout Actions | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: "microsoft/vscode-github-triage-actions" | |
| path: ./actions | |
| ref: 066bee9cefa6f0b4bf306040ff36fc7d96a6d56d # locker action commit sha | |
| - name: Install Actions | |
| run: npm install --production --prefix ./actions | |
| - name: Run Locker | |
| uses: ./actions/locker | |
| with: | |
| daysSinceClose: ${{ fromJson(inputs.daysSinceClose || 30) }} | |
| daysSinceUpdate: ${{ fromJson(inputs.daysSinceUpdate || 30) }} | |
| unlock: | |
| runs-on: ubuntu-latest | |
| # Only run the unlocking job when issues or PRs are reopened | |
| if: ${{ github.repository_owner == 'dotnet' && (github.event_name == 'issues' || github.event_name == 'pull_request_target') && github.event.action == 'reopened' }} | |
| steps: | |
| - name: Unlock if issue/PR is locked | |
| uses: actions/github-script@v7 | |
| if: ${{ github.event.issue.locked == true }} | |
| with: | |
| script: | | |
| console.log(`Unlocking locked issue/PR #${context.issue.number}.`); | |
| await github.rest.issues.unlock({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| }); |