From bc78de3a521f65f756579fee0996ec5c81f3af73 Mon Sep 17 00:00:00 2001 From: lauren Date: Fri, 7 Feb 2025 16:34:26 -0500 Subject: [PATCH 1/2] [ci] Use 'opened' event for discord notifications (#32332) We don't need to wait for it to be labeled now that we have the shared maintainer check workflow. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32332). * #32333 * __->__ #32332 --- .github/workflows/compiler_discord_notify.yml | 4 ++-- .github/workflows/runtime_discord_notify.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/compiler_discord_notify.yml b/.github/workflows/compiler_discord_notify.yml index 1ab9c1b1af..da85190dd2 100644 --- a/.github/workflows/compiler_discord_notify.yml +++ b/.github/workflows/compiler_discord_notify.yml @@ -2,7 +2,7 @@ name: (Compiler) Discord Notify on: pull_request_target: - types: [labeled] + types: [opened] paths: - compiler/** - .github/workflows/compiler_**.yml @@ -14,7 +14,7 @@ jobs: actor: ${{ github.event.pull_request.user.login }} notify: - if: ${{ needs.check_maintainer.outputs.is_core_team == 'true' && github.event.label.name == 'React Core Team' }} + if: ${{ needs.check_maintainer.outputs.is_core_team == 'true' }} needs: check_maintainer runs-on: ubuntu-latest steps: diff --git a/.github/workflows/runtime_discord_notify.yml b/.github/workflows/runtime_discord_notify.yml index 59a1078b49..5a138ce71b 100644 --- a/.github/workflows/runtime_discord_notify.yml +++ b/.github/workflows/runtime_discord_notify.yml @@ -2,7 +2,7 @@ name: (Runtime) Discord Notify on: pull_request_target: - types: [labeled] + types: [opened] paths-ignore: - compiler/** - .github/workflows/compiler_**.yml @@ -14,7 +14,7 @@ jobs: actor: ${{ github.event.pull_request.user.login }} notify: - if: ${{ needs.check_maintainer.outputs.is_core_team == 'true' && github.event.label.name == 'React Core Team' }} + if: ${{ needs.check_maintainer.outputs.is_core_team == 'true' }} needs: check_maintainer runs-on: ubuntu-latest steps: From 5cd898d395bb3ca743824d0683d237757b338bf8 Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Fri, 7 Feb 2025 17:36:21 -0500 Subject: [PATCH 2/2] [ci] Disallow PRs against builds branch Our internal build infra relies on a 1:1 mapping between `main` and the 2 build branches. Directly committing changes to those branches breaks that infra. Adds a simple workflow to leave a comment and decline the PR. --- .../shared_close_direct_sync_branch_prs.yml | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/shared_close_direct_sync_branch_prs.yml diff --git a/.github/workflows/shared_close_direct_sync_branch_prs.yml b/.github/workflows/shared_close_direct_sync_branch_prs.yml new file mode 100644 index 0000000000..4488672bd3 --- /dev/null +++ b/.github/workflows/shared_close_direct_sync_branch_prs.yml @@ -0,0 +1,38 @@ +name: (Shared) Close Direct Sync Branch PRs + +on: + pull_request: + branches: + - builds/facebook-www + - builds/facebook-fbsource + +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: + close_pr: + runs-on: ubuntu-latest + steps: + - name: Close PR + uses: actions/github-script@v7 + with: + script: | + const owner = context.repo.owner; + const repo = context.repo.repo; + const pullNumber = ${{ github.event.number }}; + + await github.rest.pulls.createReview({ + owner, + repo, + pull_number: pullNumber, + body: 'Do not commit changes directly to ${{ github.event.pull_request.base.ref }}', + event: 'REQUEST_CHANGES' + }); + await github.rest.pulls.update({ + owner, + repo, + pull_number: pullNumber, + state: 'closed' + });