Skip to content

Commit 058012b

Browse files
authored
feat: Add team label implementation (#27)
* feat: get teams * feat: use gh cli * fix: org * Update add-team-label.yml * Update add-team-label-test.yml * fix: permissions * Update add-team-label.yml * Update add-team-label.yml * Update add-team-label.yml * Update add-team-label.yml * Update add-team-label.yml * Update add-team-label.yml * feat: secret * Update add-team-label-test.yml * Update add-team-label-test.yml * Update add-team-label.yml * Update add-team-label.yml * Update add-team-label.yml * Update add-team-label.yml * Update add-team-label.yml * fix: token * Update add-team-label.yml * Update add-team-label.yml * Update add-team-label.yml * Update add-team-label.yml * Update add-team-label.yml * Update add-team-label.yml * fix: token * Update add-team-label-test.yml * Update add-team-label.yml * Update add-team-label.yml * Update add-team-label.yml * Update add-team-label-test.yml * fix: permissions * Update add-team-label.yml * Update add-team-label-test.yml * Update add-team-label-test.yml
1 parent 7c10eb3 commit 058012b

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Add team label
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
8+
jobs:
9+
add-team-label:
10+
uses: ./.github/workflows/add-team-label.yml
11+
permissions:
12+
pull-requests: write
13+
secrets:
14+
PERSONAL_ACCESS_TOKEN: ${{ secrets.LABEL_TOKEN }}

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

+17-7
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,23 @@ jobs:
1010
add-team-label:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- name: Checkout repository
14-
uses: actions/checkout@v4
15-
16-
- name: Setup environment
17-
uses: metamask/github-tools/.github/actions/setup-environment@main
13+
- name: Get team label
14+
id: get-team-label
15+
env:
16+
GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
17+
USER: ${{ github.event.pull_request.user.login }}
18+
run: |
19+
team_label=$(gh api -H 'Accept: application/vnd.github.raw' 'repos/metamask/metamask-planning/contents/teams.json' --jq ".\"$USER\"")
20+
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"
22+
exit 1
23+
fi
24+
echo 'TEAM_LABEL='"$team_label" >> "$GITHUB_OUTPUT"
1825
1926
- name: Add team label
2027
env:
21-
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
22-
run: yarn run add-team-label
28+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
PULL_REQUEST_URL: ${{ github.event.pull_request.html_url }}
30+
TEAM_LABEL: ${{ steps.get-team-label.outputs.TEAM_LABEL }}
31+
run: |
32+
gh pr edit "$PULL_REQUEST_URL" --add-label "$TEAM_LABEL"

0 commit comments

Comments
 (0)