Skip to content

Commit

Permalink
[ci] Use shared maintainer check for discord notifications
Browse files Browse the repository at this point in the history
Uses the shared maintainer check workflow across the various workflows that need it
  • Loading branch information
poteto committed Jan 16, 2025
1 parent dcf3843 commit 02f9275
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 21 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/compiler_discord_notify.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
name: (Compiler) Discord Notify

on:
pull_request_target:
types: [labeled]
pull_request:
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
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/runtime_discord_notify.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
name: (Runtime) Discord Notify

on:
pull_request_target:
types: [labeled]
pull_request:
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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
name: (Shared) Core Label
name: (Shared) Check maintainer

on:
pull_request:
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:
core_label:
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_maintainer
id: check_if_actor_is_maintainer
uses: actions/github-script@v7
with:
script: |
Expand All @@ -28,14 +33,3 @@ jobs:
}
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']
});
29 changes: 29 additions & 0 deletions .github/workflows/shared_label_core_team_prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: (Shared) Label Core Team PRs

on:
pull_request:

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']
});

0 comments on commit 02f9275

Please sign in to comment.