github.com/bluenviron/mediacommon@v1.9.3/.github/workflows/issue-lock.yml (about) 1 name: issue-lock 2 3 on: 4 schedule: 5 - cron: '40 15 * * *' 6 workflow_dispatch: 7 8 jobs: 9 issue-lock: 10 runs-on: ubuntu-latest 11 12 steps: 13 - uses: actions/github-script@v6 14 with: 15 github-token: ${{ secrets.GITHUB_TOKEN }} 16 script: | 17 const { repo: { owner, repo } } = context; 18 19 const now = new Date(); 20 21 for await (const res of github.paginate.iterator( 22 github.rest.issues.listForRepo, { 23 owner, 24 repo, 25 state: 'closed', 26 })) { 27 for (const issue of res.data) { 28 if (issue.locked) { 29 continue; 30 } 31 32 if ((now - new Date(issue.updated_at)) < 1000*60*60*24*31*6) { 33 continue; 34 } 35 36 if (!issue.pull_request) { 37 await github.rest.issues.createComment({ 38 owner, 39 repo, 40 issue_number: issue.number, 41 body: 'This issue is being locked automatically because it has been closed for more than 6 months.\n' 42 + 'Please open a new issue in case you encounter a similar problem.', 43 }); 44 } 45 46 github.rest.issues.lock({ 47 owner, 48 repo, 49 issue_number: issue.number, 50 }); 51 } 52 }