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