From 1203eb86d4c55928f31c470a2b1cd4a63c914d64 Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Thu, 16 Jan 2025 14:09:55 -0500 Subject: [PATCH] [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