From 5cd898d395bb3ca743824d0683d237757b338bf8 Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Fri, 7 Feb 2025 17:36:21 -0500 Subject: [PATCH] [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' + });