|
| 1 | +name: issue-label-automation |
| 2 | +on: |
| 3 | + pull_request_target: |
| 4 | + types: [opened] |
| 5 | + issues: |
| 6 | + types: [opened] |
| 7 | +jobs: |
| 8 | + automate-labels: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + permissions: |
| 11 | + issues: write |
| 12 | + pull-requests: write |
| 13 | + env: |
| 14 | + IS_BOT: ${{ (github.actor == 'dependabot[bot]' || github.actor == 'mergify[bot]') }} |
| 15 | + IS_HUMAN: ${{ !(github.actor == 'dependabot[bot]' || github.actor == 'mergify[bot]') }} |
| 16 | + steps: |
| 17 | + - name: Check if issue or PR was created by external contributor |
| 18 | + if: env.IS_HUMAN == 'true' && github.repository_owner == 'celestiaorg' |
| 19 | + uses: tspascoal/get-user-teams-membership@v3 |
| 20 | + id: teamCheck |
| 21 | + with: |
| 22 | + username: ${{ github.actor }} |
| 23 | + team: "celestia-core" |
| 24 | + GITHUB_TOKEN: ${{ secrets.PAT_TEAM_CHECK }} |
| 25 | + |
| 26 | + # If an issue was unlabeled add `needs:triage`. |
| 27 | + - name: Maybe label issue with `needs:triage` |
| 28 | + if: ${{ github.event_name == 'issues' }} |
| 29 | + uses: andymckay/labeler@master |
| 30 | + with: |
| 31 | + add-labels: "needs:triage" |
| 32 | + ignore-if-labeled: true |
| 33 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 34 | + |
| 35 | + # If an issue or PR was created by someone that isn't part of |
| 36 | + # celestia-core, add the `external` label. |
| 37 | + - name: Maybe label issue or PR with `external` |
| 38 | + if: env.IS_HUMAN == 'true' && steps.teamCheck.outputs.isTeamMember == 'false' |
| 39 | + uses: andymckay/labeler@master |
| 40 | + with: |
| 41 | + add-labels: "external" |
| 42 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 43 | + |
| 44 | + # If a PR was created by dependabot or mergify add the `bot` label. |
| 45 | + - name: Maybe label PR with `bot` |
| 46 | + if: env.IS_BOT == 'true' |
| 47 | + uses: andymckay/labeler@master |
| 48 | + with: |
| 49 | + add-labels: "bot" |
| 50 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments