This GitHub CLI extension can be used to label a pull request with team names that the author of the pull request is part of.
From the commandline:
gh extension install koozz/gh-teamlabel # Just once
gh teamlabel -org my-org team1_slug:Team1Label team2_slug:Team2Label
In GitHub Actions, add a step like this:
- name: Team labeling
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh extension install koozz/gh-teamlabel --pin 2.0.3
gh teamlabel -org my-org team1_slug:Team1Label team2_slug:Team2Label
The used GitHub token must have enough privileges, either use a GitHub App or a Personal Access Token.
Adding labels on a pull request only works if these labels have been added to the repository.
You could prepend the above scripts with calls to gh label create
gh label create Team1Label --color 336699 --description "Team one label description" --force
gh label create Team2Label --color 336699 --description "Team two label description" --force
gh teamlabel -org my-org team1:Team1Label team2:Team2Label
MIT