Skip to content

Commit ddfa71e

Browse files
authored
fix(add-team-label): fall back to team-bots for bot accounts (#327)
1 parent 59cca34 commit ddfa71e

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎.github/actions/add-team-label/action.yml‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Add Team Label
2-
description: "Adds a GitHub team label to a pull request based on the author's entry in the MetaMask topology file. Skips if the PR already has a team-* or external-contributor label."
2+
description: "Adds a GitHub team label to a pull request based on the author's entry in the MetaMask topology file. Skips if the PR already has a team-* or external-contributor label, and falls back to team-bots for bot accounts missing from the topology file."
33

44
inputs:
55
team-label-token:
@@ -37,11 +37,16 @@ runs:
3737
env:
3838
GH_TOKEN: ${{ inputs.planning-token || inputs.team-label-token }}
3939
USER: ${{ github.event.pull_request.user.login }}
40+
AUTHOR_TYPE: ${{ github.event.pull_request.user.type }}
4041
shell: bash
4142
run: |
4243
# Stream topology.json through jq, find the first team where USER appears in members, pm, em, or tl, and emit
4344
# its githubLabel.name value.
4445
team_label=$(gh api -H 'Accept: application/vnd.github.raw' 'repos/metamask/metamask-planning/contents/topology.json' | jq -r --arg USER "$USER" '.[] | select(any(.members[]?; . == $USER) or (.pm // empty) == $USER or (.em // empty) == $USER or (.tl // empty) == $USER) | .githubLabel.name' | head -n 1)
46+
# A GitHub App (type Bot) missing from the topology file still belongs to the bots team.
47+
if [ -z "$team_label" ] && [ "$AUTHOR_TYPE" = "Bot" ]; then
48+
team_label=team-bots
49+
fi
4550
if [ -z "$team_label" ]; then
4651
echo "::error::Team label not found for author: $USER. Please open a pull request with your GitHub handle and team label to update topology.json at https://github.com/MetaMask/MetaMask-planning/blob/main/topology.json"
4752
exit 1

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- Fall back to the `team-bots` label in `add-team-label` for bot authors missing from `topology.json` ([#327](https://github.com/MetaMask/github-tools/pull/327))
13+
1014
## [1.24.0]
1115

1216
### Changed

0 commit comments

Comments
 (0)