From 8c82a0302352e9c797346185bc1fcc5f2dde4475 Mon Sep 17 00:00:00 2001 From: Pavel Dvorkin Date: Wed, 8 Oct 2025 14:48:32 -0400 Subject: [PATCH 1/3] MCRM-8-Updated add-team-label worklow to use topology.json --- .github/workflows/add-team-label.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/add-team-label.yml b/.github/workflows/add-team-label.yml index 8b81b00c..9fa7efd0 100644 --- a/.github/workflows/add-team-label.yml +++ b/.github/workflows/add-team-label.yml @@ -1,3 +1,4 @@ +# Adds a GitHub team label to a pull request based on the author's entry in the MetaMask topology file. name: Add team label on: @@ -10,19 +11,22 @@ jobs: add-team-label: runs-on: ubuntu-latest steps: + # Fetch the team label for the PR author from topology.json and expose it as a step output. - name: Get team label id: get-team-label env: GH_TOKEN: ${{ secrets.TEAM_LABEL_TOKEN }} USER: ${{ github.event.pull_request.user.login }} run: | - team_label=$(gh api -H 'Accept: application/vnd.github.raw' 'repos/metamask/metamask-planning/contents/teams.json' --jq ".\"$USER\"") + # Stream topology.json through jq, find the first team whose members array contains the USER, 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((.members // []) | index($USER)) | .githubLabel.name' | head -n 1) 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 teams.json at https://github.com/MetaMask/MetaMask-planning/blob/main/teams.json" + 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 fi echo 'TEAM_LABEL='"$team_label" >> "$GITHUB_OUTPUT" + # Apply the retrieved label to the pull request using the GitHub CLI. - name: Add team label env: GH_TOKEN: ${{ secrets.TEAM_LABEL_TOKEN }} From b46ffbaf93ba87ae49aa66b8425f48b584a97345 Mon Sep 17 00:00:00 2001 From: Pavel Dvorkin Date: Thu, 9 Oct 2025 14:51:52 -0400 Subject: [PATCH 2/3] MRCM-8-Updated add-team-label to also look at pm, em, and tl fields --- .github/workflows/add-team-label.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/add-team-label.yml b/.github/workflows/add-team-label.yml index 9fa7efd0..3c8e04dc 100644 --- a/.github/workflows/add-team-label.yml +++ b/.github/workflows/add-team-label.yml @@ -18,8 +18,8 @@ jobs: GH_TOKEN: ${{ secrets.TEAM_LABEL_TOKEN }} USER: ${{ github.event.pull_request.user.login }} run: | - # Stream topology.json through jq, find the first team whose members array contains the USER, 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((.members // []) | index($USER)) | .githubLabel.name' | head -n 1) + # Stream topology.json through jq, find the first team where USER matches any of the members, pm, em or tl fields, 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((.members // []) | index($USER) or (.pm // empty) == $USER or (.em // empty) == $USER or (.tl // empty) == $USER) | .githubLabel.name' | head -n 1) 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 From a9fbd72b8f931881ab331612f3e69573874a7da1 Mon Sep 17 00:00:00 2001 From: Pavel Dvorkin Date: Thu, 9 Oct 2025 15:13:51 -0400 Subject: [PATCH 3/3] MRCM-8-Updated add-team-label to also look at pm, em, and tl fields --- .github/workflows/add-team-label.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/add-team-label.yml b/.github/workflows/add-team-label.yml index 3c8e04dc..132fc6d3 100644 --- a/.github/workflows/add-team-label.yml +++ b/.github/workflows/add-team-label.yml @@ -18,8 +18,8 @@ jobs: GH_TOKEN: ${{ secrets.TEAM_LABEL_TOKEN }} USER: ${{ github.event.pull_request.user.login }} run: | - # Stream topology.json through jq, find the first team where USER matches any of the members, pm, em or tl fields, 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((.members // []) | index($USER) or (.pm // empty) == $USER or (.em // empty) == $USER or (.tl // empty) == $USER) | .githubLabel.name' | head -n 1) + # 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) 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