diff --git a/.github/workflows/shared_check_maintainer.yml b/.github/workflows/shared_check_maintainer.yml index cd43ffe559..fcfdf70590 100644 --- a/.github/workflows/shared_check_maintainer.yml +++ b/.github/workflows/shared_check_maintainer.yml @@ -6,6 +6,10 @@ on: actor: required: true type: string + use_local: + required: false + type: boolean + default: false outputs: is_core_team: value: ${{ jobs.check_maintainer.outputs.is_core_team }} @@ -29,8 +33,30 @@ jobs: script: | const fs = require('fs'); const actor = '${{ inputs.actor }}'; - const data = await fs.readFileSync('./MAINTAINERS', { encoding: 'utf8' }); - const maintainers = new Set(data.split('\n')); + const useLocal = ${{ inputs.use_local }}; + + let content = null; + if (useLocal) { + content = await fs.readFileSync('./MAINTAINERS', { encoding: 'utf8' }); + } else { + const res = await github.rest.repos.getContent({ + owner: 'facebook', + repo: 'react', + path: 'MAINTAINERS', + ref: 'main', + headers: { Accept: 'application/vnd.github+json' } + }); + if (res.status !== 200) { + console.error(res); + throw new Error('Unable to fetch MAINTAINERS file'); + } + const content = Buffer.from(res.data.content, 'base64'); + } + if (content === null) { + throw new Error('Unable to retrieve local or http MAINTAINERS file'); + } + + const maintainers = new Set(content.split('\n')); if (maintainers.has(actor)) { console.log(`🟢 ${actor} is a maintainer`); return true; diff --git a/.github/workflows/shared_label_core_team_prs.yml b/.github/workflows/shared_label_core_team_prs.yml index dc432b54f7..e08b083a9e 100644 --- a/.github/workflows/shared_label_core_team_prs.yml +++ b/.github/workflows/shared_label_core_team_prs.yml @@ -1,7 +1,7 @@ name: (Shared) Label Core Team PRs on: - pull_request_target: + pull_request: env: TZ: /usr/share/zoneinfo/America/Los_Angeles @@ -10,7 +10,7 @@ env: jobs: check_maintainer: - uses: facebook/react/.github/workflows/shared_check_maintainer.yml@main + uses: facebook/react/.github/workflows/shared_check_maintainer.yml@pr32215 with: actor: ${{ github.event.pull_request.user.login }}