|
| 1 | +name: Triage Issues and PRs |
| 2 | + |
| 3 | +on: |
| 4 | + issues: |
| 5 | + types: [opened, edited] |
| 6 | + pull_request: |
| 7 | + types: [opened, edited] |
| 8 | + |
| 9 | +jobs: |
| 10 | + triage: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Assign Labels |
| 15 | + if: github.event.issue |
| 16 | + uses: actions/github-script@v6 |
| 17 | + with: |
| 18 | + script: | |
| 19 | + const issue = context.issue; |
| 20 | + const labels = []; |
| 21 | + if (issue.title.includes('bug')) { |
| 22 | + labels.push('bug'); |
| 23 | + } else if (issue.title.includes('feature')) { |
| 24 | + labels.push('enhancement'); |
| 25 | + } else { |
| 26 | + labels.push('needs-triage'); |
| 27 | + } |
| 28 | + github.issues.addLabels({ |
| 29 | + owner: context.repo.owner, |
| 30 | + repo: context.repo.repo, |
| 31 | + issue_number: issue.number, |
| 32 | + labels: labels |
| 33 | + }); |
| 34 | +
|
| 35 | + - name: Assign Issues |
| 36 | + if: github.event.issue |
| 37 | + uses: actions/github-script@v6 |
| 38 | + with: |
| 39 | + script: | |
| 40 | + const issue = context.issue; |
| 41 | + const assignees = []; |
| 42 | + if (issue.title.includes('bug')) { |
| 43 | + assignees.push('bug-fixer'); |
| 44 | + } else if (issue.title.includes('feature')) { |
| 45 | + assignees.push('feature-dev'); |
| 46 | + } |
| 47 | + github.issues.addAssignees({ |
| 48 | + owner: context.repo.owner, |
| 49 | + repo: context.repo.repo, |
| 50 | + issue_number: issue.number, |
| 51 | + assignees: assignees |
| 52 | + }); |
| 53 | +
|
| 54 | + - name: Add Comment |
| 55 | + if: github.event.issue |
| 56 | + uses: actions/github-script@v6 |
| 57 | + with: |
| 58 | + script: | |
| 59 | + const issue = context.issue; |
| 60 | + const comment = `Thank you for your ${issue.title.includes('bug') ? 'bug report' : 'feature request'}! We will review it soon.`; |
| 61 | + github.issues.createComment({ |
| 62 | + owner: context.repo.owner, |
| 63 | + repo: context.repo.repo, |
| 64 | + issue_number: issue.number, |
| 65 | + body: comment |
| 66 | + }); |
| 67 | +
|
| 68 | + - name: Close Stale Issues |
| 69 | + uses: actions/stale@v4 |
| 70 | + with: |
| 71 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 72 | + stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.' |
| 73 | + stale-pr-message: 'This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.' |
| 74 | + days-before-stale: 30 |
| 75 | + days-before-close: 7 |
0 commit comments