From 1203eb86d4c55928f31c470a2b1cd4a63c914d64 Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Thu, 16 Jan 2025 14:09:55 -0500 Subject: [PATCH 1/2] [ci] Automatically label PRs from core team Adds a new `MAINTAINERS` file which contains github usernames of core team members. This file serves as documentation for core team membership and is also used to automatically label PRs from core. --- .github/workflows/shared_core_label.yml | 41 +++++++++++++++++++++++++ MAINTAINERS | 23 ++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 .github/workflows/shared_core_label.yml create mode 100644 MAINTAINERS diff --git a/.github/workflows/shared_core_label.yml b/.github/workflows/shared_core_label.yml new file mode 100644 index 0000000000000..da2c45465eee9 --- /dev/null +++ b/.github/workflows/shared_core_label.yml @@ -0,0 +1,41 @@ +name: (Shared) Core Label + +on: + pull_request_target: + +env: + TZ: /usr/share/zoneinfo/America/Los_Angeles + # https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cache-segment-restore-timeout + SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1 + +jobs: + core_label: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Check if actor is maintainer + id: check_maintainer + uses: actions/github-script@v7 + with: + script: | + const fs = require('fs'); + const actor = '${{ github.actor }}'; + const data = await fs.readFileSync('./MAINTAINERS', { encoding: 'utf8' }); + const maintainers = new Set(data.split('\n')); + if (maintainers.has(actor)) { + console.log(`🟢 ${actor} is a maintainer`); + return true; + } + console.log(`🔴 ${actor} is NOT a maintainer`); + return null; + - name: Label PR as React Core Team + if: ${{ steps.check_maintainer.outputs.result }} + uses: actions/github-script@v7 + with: + script: | + github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: ${{ github.event.number }}, + labels: ['React Core Team'] + }); diff --git a/MAINTAINERS b/MAINTAINERS new file mode 100644 index 0000000000000..3eda4c5b2d382 --- /dev/null +++ b/MAINTAINERS @@ -0,0 +1,23 @@ +acdlite +bvaughn +eps1lon +gaearon +gnoff +gsathya +hoxyq +jackpope +jbonta +josephsavona +kassens +lunaleaps +mattcarrollcode +mofeiZ +noahlemen +poteto +rickhanlonii +sebmarkbage +sethwebster +sophiebits +TheSavior +tyao1 +yuzhi From cf82f76ee682d8f568f16ceb2abdbf4b8484bc8a Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Thu, 16 Jan 2025 14:11:10 -0500 Subject: [PATCH 2/2] [ci] Use shared maintainer check for discord notifications Uses the shared maintainer check workflow across the various workflows that need it --- .github/workflows/compiler_discord_notify.yml | 7 +++-- .github/workflows/runtime_discord_notify.yml | 7 +++-- ..._label.yml => shared_check_maintainer.yml} | 24 ++++++--------- .../workflows/shared_label_core_team_prs.yml | 29 +++++++++++++++++++ 4 files changed, 48 insertions(+), 19 deletions(-) rename .github/workflows/{shared_core_label.yml => shared_check_maintainer.yml} (62%) create mode 100644 .github/workflows/shared_label_core_team_prs.yml diff --git a/.github/workflows/compiler_discord_notify.yml b/.github/workflows/compiler_discord_notify.yml index 3eeb009a78aab..febd55764b7a7 100644 --- a/.github/workflows/compiler_discord_notify.yml +++ b/.github/workflows/compiler_discord_notify.yml @@ -2,14 +2,17 @@ name: (Compiler) Discord Notify on: pull_request_target: - types: [labeled] paths: - compiler/** - .github/workflows/compiler_**.yml jobs: + check_maintainer: + uses: facebook/react/.github/workflows/shared_check_maintainer.yml@main + notify: - if: ${{ github.event.label.name == 'React Core Team' }} + if: ${{ needs.check_maintainer.outputs.is_core_team }} + needs: check_maintainer runs-on: ubuntu-latest steps: - name: Discord Webhook Action diff --git a/.github/workflows/runtime_discord_notify.yml b/.github/workflows/runtime_discord_notify.yml index 93606cd549873..18304046d7767 100644 --- a/.github/workflows/runtime_discord_notify.yml +++ b/.github/workflows/runtime_discord_notify.yml @@ -2,14 +2,17 @@ name: (Runtime) Discord Notify on: pull_request_target: - types: [labeled] paths-ignore: - compiler/** - .github/workflows/compiler_**.yml jobs: + check_maintainer: + uses: facebook/react/.github/workflows/shared_check_maintainer.yml@main + notify: - if: ${{ github.event.label.name == 'React Core Team' }} + if: ${{ needs.check_maintainer.outputs.is_core_team }} + needs: check_maintainer runs-on: ubuntu-latest steps: - name: Discord Webhook Action diff --git a/.github/workflows/shared_core_label.yml b/.github/workflows/shared_check_maintainer.yml similarity index 62% rename from .github/workflows/shared_core_label.yml rename to .github/workflows/shared_check_maintainer.yml index da2c45465eee9..53f4c7a8af046 100644 --- a/.github/workflows/shared_core_label.yml +++ b/.github/workflows/shared_check_maintainer.yml @@ -1,7 +1,10 @@ -name: (Shared) Core Label +name: (Shared) Check maintainer on: - pull_request_target: + workflow_call: + outputs: + is_core_team: + value: ${{ jobs.check_maintainer.outputs.is_core_team }} env: TZ: /usr/share/zoneinfo/America/Los_Angeles @@ -9,12 +12,14 @@ env: SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1 jobs: - core_label: + check_maintainer: runs-on: ubuntu-latest + outputs: + is_core_team: ${{ steps.check_if_actor_is_maintainer.outputs.result }} steps: - uses: actions/checkout@v4 - name: Check if actor is maintainer - id: check_maintainer + id: check_if_actor_is_maintainer uses: actions/github-script@v7 with: script: | @@ -28,14 +33,3 @@ jobs: } console.log(`🔴 ${actor} is NOT a maintainer`); return null; - - name: Label PR as React Core Team - if: ${{ steps.check_maintainer.outputs.result }} - uses: actions/github-script@v7 - with: - script: | - github.rest.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: ${{ github.event.number }}, - labels: ['React Core Team'] - }); diff --git a/.github/workflows/shared_label_core_team_prs.yml b/.github/workflows/shared_label_core_team_prs.yml new file mode 100644 index 0000000000000..b96aea88054fa --- /dev/null +++ b/.github/workflows/shared_label_core_team_prs.yml @@ -0,0 +1,29 @@ +name: (Shared) Label Core Team PRs + +on: + pull_request_target: + +env: + TZ: /usr/share/zoneinfo/America/Los_Angeles + # https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cache-segment-restore-timeout + SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1 + +jobs: + check_maintainer: + uses: facebook/react/.github/workflows/shared_check_maintainer.yml@main + + label: + if: ${{ needs.check_maintainer.outputs.is_core_team }} + runs-on: ubuntu-latest + needs: check_maintainer + steps: + - name: Label PR as React Core Team + uses: actions/github-script@v7 + with: + script: | + github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: ${{ github.event.number }}, + labels: ['React Core Team'] + });