Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/actions/add-team-label/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Add Team Label
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."
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."

inputs:
team-label-token:
Expand Down Expand Up @@ -37,11 +37,16 @@ runs:
env:
GH_TOKEN: ${{ inputs.planning-token || inputs.team-label-token }}
USER: ${{ github.event.pull_request.user.login }}
AUTHOR_TYPE: ${{ github.event.pull_request.user.type }}
shell: bash
run: |
# Stream topology.json through jq, find the first team where USER appears in members, pm, em, or tl, and emit
# its githubLabel.name value.
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)
# A GitHub App (type Bot) missing from the topology file still belongs to the bots team.
if [ -z "$team_label" ] && [ "$AUTHOR_TYPE" = "Bot" ]; then
team_label=team-bots
fi
if [ -z "$team_label" ]; then
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"
exit 1
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- 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))

## [1.24.0]

### Changed
Expand Down
Loading