[ci] Use shared maintainer check for discord notifications (#32101)

Uses the shared maintainer check workflow across the various workflows
that need it
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32101).
* __->__ #32101
* #32100
This commit is contained in:
lauren authored and GitHub committed 2025-01-16 14:21:55 -05:00
1 parent af4987e19f
commit 60c797e744
4 files changed
+74 -4

No files matched your search

@@ -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
+5 -2
View File
@@ -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
@@ -0,0 +1,35 @@
name: (Shared) Check maintainer
on:
workflow_call:
outputs:
is_core_team:
value: ${{ jobs.check_maintainer.outputs.is_core_team }}
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:
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_if_actor_is_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;
@@ -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']
});