[ci] Disallow PRs against builds branch (#32335)
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.
lauren committed
Feb 7, 2025 at 17:49 UTC
7588b6b291b17fb2130244115b07e9945a864626
1 file changed
+37
.github/workflows/shared_close_direct_sync_branch_prs.yml
new
+37
@@ -0,0 +1,37 @@
1
+name: (Shared) Close Direct Sync Branch PRs
2
+
3
+on:
4
+ pull_request:
5
+ branches:
6
+ - builds/facebook-*
7
+
8
+env:
9
+ TZ: /usr/share/zoneinfo/America/Los_Angeles
10
+ # https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cache-segment-restore-timeout
11
+ SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
12
+
13
+jobs:
14
+ close_pr:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - name: Close PR
18
+ uses: actions/github-script@v7
19
+ with:
20
+ script: |
21
+ const owner = context.repo.owner;
22
+ const repo = context.repo.repo;
23
+ const pullNumber = ${{ github.event.number }};
24
+
25
+ await github.rest.pulls.createReview({
26
+ owner,
27
+ repo,
28
+ pull_number: pullNumber,
29
+ body: 'Do not land changes to `${{ github.event.pull_request.base.ref }}`. Please re-open your PR targeting `main` instead.',
30
+ event: 'REQUEST_CHANGES'
31
+ });
32
+ await github.rest.pulls.update({
33
+ owner,
34
+ repo,
35
+ pull_number: pullNumber,
36
+ state: 'closed'
37
+ });