Skip to content

Commit 7fe185f

Browse files
authored
MCRM-8-Updated add-team-label worklow to use topology.json (#137)
* MCRM-8-Updated add-team-label worklow to use topology.json * MRCM-8-Updated add-team-label to also look at pm, em, and tl fields * MRCM-8-Updated add-team-label to also look at pm, em, and tl fields
1 parent bb4f212 commit 7fe185f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

.github/workflows/add-team-label.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Adds a GitHub team label to a pull request based on the author's entry in the MetaMask topology file.
12
name: Add team label
23

34
on:
@@ -10,19 +11,22 @@ jobs:
1011
add-team-label:
1112
runs-on: ubuntu-latest
1213
steps:
14+
# Fetch the team label for the PR author from topology.json and expose it as a step output.
1315
- name: Get team label
1416
id: get-team-label
1517
env:
1618
GH_TOKEN: ${{ secrets.TEAM_LABEL_TOKEN }}
1719
USER: ${{ github.event.pull_request.user.login }}
1820
run: |
19-
team_label=$(gh api -H 'Accept: application/vnd.github.raw' 'repos/metamask/metamask-planning/contents/teams.json' --jq ".\"$USER\"")
21+
# Stream topology.json through jq, find the first team where USER appears in members, pm, em, or tl, and emit its githubLabel.name value.
22+
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)
2023
if [ -z "$team_label" ]; then
21-
echo "::error::Team label not found for author: $USER. Please open a pull request with your GitHub handle and team label to update teams.json at https://github.com/MetaMask/MetaMask-planning/blob/main/teams.json"
24+
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"
2225
exit 1
2326
fi
2427
echo 'TEAM_LABEL='"$team_label" >> "$GITHUB_OUTPUT"
2528
29+
# Apply the retrieved label to the pull request using the GitHub CLI.
2630
- name: Add team label
2731
env:
2832
GH_TOKEN: ${{ secrets.TEAM_LABEL_TOKEN }}

0 commit comments

Comments
 (0)