123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- name: Close inactive issues
- on:
- schedule:
- - cron: "10 23 * * *"
- jobs:
- close-issues:
- runs-on: ubuntu-latest
- permissions:
- issues: write
- pull-requests: write
- steps:
- - uses: actions/stale@v5
- with:
- stale-issue-message: ""
- close-issue-message: "This issue has been closed due to inactivity for 6 weeks. If you believe it is still relevant, please leave a comment below. You can tag a developer in your comment."
- days-before-issue-stale: 42
- days-before-issue-close: 0
- stale-issue-label: "stale"
- days-before-pr-stale: -1
- days-before-pr-close: -1
- repo-token: ${{ secrets.GITHUB_TOKEN }}
- - name: Close issues without label or comment
- uses: actions/github-script@v3
- with:
- github-token: ${{secrets.GITHUB_TOKEN}}
- script: |
- const repo = context.repo;
- let page = 1;
- let issues = [];
- while (true) {
- const result = await github.issues.listForRepo({...repo, per_page: 100, page: page});
- if (result.data.length === 0) break;
- issues = issues.concat(result.data);
- page += 1;
- }
- for (let { number } of issues) {
- const issueData = await github.issues.get({...repo, issue_number: number});
- const comments = await github.issues.listComments({...repo, issue_number: number});
- if (issueData.data.labels.length === 0 && comments.data.length < 1) {
- await github.issues.update({...repo, issue_number: number, state: 'closed'});
- await github.issues.createComment({...repo, issue_number: number, body: 'Issue closed as it does not have any labels or comments.'});
- }
- }
|