| 1 | name: (Shared) Close Direct Sync Branch PRs |
| 2 | |
| 3 | on: |
| 4 | pull_request: |
| 5 | branches: |
| 6 | - 'builds/facebook-**' |
| 7 | |
| 8 | permissions: {} |
| 9 | |
| 10 | env: |
| 11 | TZ: /usr/share/zoneinfo/America/Los_Angeles |
| 12 | # https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cache-segment-restore-timeout |
| 13 | SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1 |
| 14 | |
| 15 | jobs: |
| 16 | close_pr: |
| 17 | runs-on: ubuntu-latest |
| 18 | permissions: |
| 19 | # Used to create a review and close PRs |
| 20 | pull-requests: write |
| 21 | contents: write |
| 22 | steps: |
| 23 | - name: Close PR |
| 24 | uses: actions/github-script@v7 |
| 25 | with: |
| 26 | script: | |
| 27 | const owner = context.repo.owner; |
| 28 | const repo = context.repo.repo; |
| 29 | const pullNumber = ${{ github.event.number }}; |
| 30 | |
| 31 | await github.rest.pulls.createReview({ |
| 32 | owner, |
| 33 | repo, |
| 34 | pull_number: pullNumber, |
| 35 | body: 'Do not land changes to `${{ github.event.pull_request.base.ref }}`. Please re-open your PR targeting `main` instead.', |
| 36 | event: 'REQUEST_CHANGES' |
| 37 | }); |
| 38 | await github.rest.pulls.update({ |
| 39 | owner, |
| 40 | repo, |
| 41 | pull_number: pullNumber, |
| 42 | state: 'closed' |
| 43 | }); |