From c797154b59813aef081a21c2d1ed862050ed9325 Mon Sep 17 00:00:00 2001 From: Kevin Bond Date: Thu, 18 Apr 2024 17:06:22 -0400 Subject: [PATCH] Auto-close PRs on subtree-splits --- .gitattributes | 1 + .github/PULL_REQUEST_TEMPLATE.md | 8 ++++++ .github/workflows/check-subtree-split.yml | 33 +++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 .gitattributes create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/check-subtree-split.yml diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8253128 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +/.git* export-ignore diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..1325301 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,8 @@ +Please do not submit any Pull Requests here. They will be closed. +--- + +Please submit your PR here instead: +https://github.com/symfony/polyfill + +This repository is what we call a "subtree split": a read-only subset of that main repository. +We're looking forward to your PR there! diff --git a/.github/workflows/check-subtree-split.yml b/.github/workflows/check-subtree-split.yml new file mode 100644 index 0000000..efc1432 --- /dev/null +++ b/.github/workflows/check-subtree-split.yml @@ -0,0 +1,33 @@ +name: Check subtree split +on: + pull_request_target: +jobs: + close-pull-request: + runs-on: ubuntu-latest + steps: + - name: Close pull request + uses: actions/github-script@v6 + with: + script: | + if (context.repo.owner === "symfony") { + github.rest.issues.createComment({ + owner: "symfony", + repo: context.repo.repo, + issue_number: context.issue.number, + body: ` + Thanks for your Pull Request! We love contributions. + + However, you should instead open your PR on the main repository: + https://github.com/symfony/polyfill + + This repository is what we call a "subtree split": a read-only subset of that main repository. + We're looking forward to your PR there! + ` + }); + github.rest.pulls.update({ + owner: "symfony", + repo: context.repo.repo, + pull_number: context.issue.number, + state: "closed" + }); + }