Skip to content

Commit 60c797e

Browse files
authored
[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
1 parent af4987e commit 60c797e

File tree

4 files changed

+74
-4
lines changed

4 files changed

+74
-4
lines changed

.github/workflows/compiler_discord_notify.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ name: (Compiler) Discord Notify
22

33
on:
44
pull_request_target:
5-
types: [labeled]
65
paths:
76
- compiler/**
87
- .github/workflows/compiler_**.yml
98

109
jobs:
10+
check_maintainer:
11+
uses: facebook/react/.github/workflows/shared_check_maintainer.yml@main
12+
1113
notify:
12-
if: ${{ github.event.label.name == 'React Core Team' }}
14+
if: ${{ needs.check_maintainer.outputs.is_core_team }}
15+
needs: check_maintainer
1316
runs-on: ubuntu-latest
1417
steps:
1518
- name: Discord Webhook Action

.github/workflows/runtime_discord_notify.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ name: (Runtime) Discord Notify
22

33
on:
44
pull_request_target:
5-
types: [labeled]
65
paths-ignore:
76
- compiler/**
87
- .github/workflows/compiler_**.yml
98

109
jobs:
10+
check_maintainer:
11+
uses: facebook/react/.github/workflows/shared_check_maintainer.yml@main
12+
1113
notify:
12-
if: ${{ github.event.label.name == 'React Core Team' }}
14+
if: ${{ needs.check_maintainer.outputs.is_core_team }}
15+
needs: check_maintainer
1316
runs-on: ubuntu-latest
1417
steps:
1518
- name: Discord Webhook Action
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: (Shared) Check maintainer
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
is_core_team:
7+
value: ${{ jobs.check_maintainer.outputs.is_core_team }}
8+
9+
env:
10+
TZ: /usr/share/zoneinfo/America/Los_Angeles
11+
# https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cache-segment-restore-timeout
12+
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
13+
14+
jobs:
15+
check_maintainer:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
is_core_team: ${{ steps.check_if_actor_is_maintainer.outputs.result }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Check if actor is maintainer
22+
id: check_if_actor_is_maintainer
23+
uses: actions/github-script@v7
24+
with:
25+
script: |
26+
const fs = require('fs');
27+
const actor = '${{ github.actor }}';
28+
const data = await fs.readFileSync('./MAINTAINERS', { encoding: 'utf8' });
29+
const maintainers = new Set(data.split('\n'));
30+
if (maintainers.has(actor)) {
31+
console.log(`🟢 ${actor} is a maintainer`);
32+
return true;
33+
}
34+
console.log(`🔴 ${actor} is NOT a maintainer`);
35+
return null;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: (Shared) Label Core Team PRs
2+
3+
on:
4+
pull_request_target:
5+
6+
env:
7+
TZ: /usr/share/zoneinfo/America/Los_Angeles
8+
# https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cache-segment-restore-timeout
9+
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
10+
11+
jobs:
12+
check_maintainer:
13+
uses: facebook/react/.github/workflows/shared_check_maintainer.yml@main
14+
15+
label:
16+
if: ${{ needs.check_maintainer.outputs.is_core_team }}
17+
runs-on: ubuntu-latest
18+
needs: check_maintainer
19+
steps:
20+
- name: Label PR as React Core Team
21+
uses: actions/github-script@v7
22+
with:
23+
script: |
24+
github.rest.issues.addLabels({
25+
owner: context.repo.owner,
26+
repo: context.repo.repo,
27+
issue_number: ${{ github.event.number }},
28+
labels: ['React Core Team']
29+
});

0 commit comments

Comments
 (0)