| 10 | label-maintainer: | 10 | label-maintainer: |
| 11 | name: Label if Author is a Repo Maintainer | 11 | name: Label if Author is a Repo Maintainer |
| 12 | runs-on: ubuntu-latest | 12 | runs-on: ubuntu-latest |
| | 13 | if: contains(fromJson('["Cohee1207", "RossAscends", "Wolfsblvt"]'), github.actor) |
| 13 | | 14 | |
| 14 | steps: | 15 | steps: |
| 15 | - name: Label if Author is a Repo Maintainer | 16 | - name: Label if Author is a Repo Maintainer |
| 16 | # GitHub Script | 17 | # 🤖 Issues Helper |
| 17 | # https://github.com/marketplace/actions/github-script | 18 | # https://github.com/marketplace/actions/issues-helper |
| 18 | uses: actions/github-script@v7 | 19 | uses: actions-cool/issues-helper@v3 |
| 19 | with: | 20 | with: |
| 20 | script: | | 21 | actions: 'add-labels' |
| 21 | // Hard-coded list of maintainer usernames | 22 | token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} |
| 22 | const maintainers = ['Cohee1207', 'RossAscends', 'Wolfsblvt']; | 23 | issue-number: ${{ github.event.issue.number || github.event.pull_request.number }} |
| 23 | | 24 | labels: '👷 Maintainer' |
| 24 | // Get event details (works for issues and pull requests) | | |
| 25 | const { owner, repo } = context.repo; | | |
| 26 | const payload = context.payload; | | |
| 27 | const eventData = payload.issue || payload.pull_request; | | |
| 28 | const username = eventData.user.login; | | |
| 29 | const issue_number = eventData.number; | | |
| 30 | | | |
| 31 | if (maintainers.includes(username)) { | | |
| 32 | console.log(`User ${username} is a maintainer. Adding "Maintainer" label to issue/PR #${issue_number}`); | | |
| 33 | await github.issues.addLabels({ | | |
| 34 | owner, | | |
| 35 | repo, | | |
| 36 | issue_number, | | |
| 37 | labels: ['👷 Maintainer'], | | |
| 38 | }); | | |
| 39 | } else { | | |
| 40 | console.log(`User ${username} is not on the maintainer list.`); | | |
| 41 | } | | |