[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
lauren committed
Jan 16, 2025 at 14:21 UTC
60c797e744636a6d39afe03edd18fb3af9e04157
4 files changed
+74
-4
.github/workflows/compiler_discord_notify.yml
+5
-2
@@ -2,14 +2,17 @@ name: (Compiler) Discord Notify
2
3
on:
4
pull_request_target:
5
- types: [labeled]
5
paths:
6
- compiler/**
7
- .github/workflows/compiler_**.yml
8
9
jobs:
10
+ check_maintainer:
11
+ uses: facebook/react/.github/workflows/shared_check_maintainer.yml@main
12
+
13
notify:
12
- if: ${{ github.event.label.name == 'React Core Team' }}
14
+ if: ${{ needs.check_maintainer.outputs.is_core_team }}
15
+ needs: check_maintainer
16
runs-on: ubuntu-latest
17
steps:
18
- name: Discord Webhook Action
.github/workflows/runtime_discord_notify.yml
+5
-2
@@ -2,14 +2,17 @@ name: (Runtime) Discord Notify
2
3
on:
4
pull_request_target:
5
- types: [labeled]
5
paths-ignore:
6
- compiler/**
7
- .github/workflows/compiler_**.yml
8
9
jobs:
10
+ check_maintainer:
11
+ uses: facebook/react/.github/workflows/shared_check_maintainer.yml@main
12
+
13
notify:
12
- if: ${{ github.event.label.name == 'React Core Team' }}
14
+ if: ${{ needs.check_maintainer.outputs.is_core_team }}
15
+ needs: check_maintainer
16
runs-on: ubuntu-latest
17
steps:
18
- name: Discord Webhook Action
.github/workflows/shared_check_maintainer.yml
new
+35
@@ -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;
.github/workflows/shared_label_core_team_prs.yml
new
+29
@@ -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
+ });