Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-close PRs on subtree-splits #1751

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/sync-packages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

if ('cli' !== PHP_SAPI) {
echo "This script can only be run from the command line.\n";
exit(1);
}

$mainRepo = 'https://github.com/symfony/ux';
exec('find src/ -name composer.json', $packages);

foreach ($packages as $package) {
$package = dirname($package);
$c = file_get_contents($package.'/.gitattributes');
$c = preg_replace('{^/\.git.*+\n}m', '', $c);
$c .= "/.git* export-ignore\n";
file_put_contents($package.'/.gitattributes', $c);


@mkdir($package.'/.github');
file_put_contents($package.'/.github/PULL_REQUEST_TEMPLATE.md', <<<EOTXT
Please do not submit any Pull Requests here. They will be closed.
---
Please submit your PR here instead:
{$mainRepo}
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!
EOTXT
);

@mkdir($package.'/.github/workflows');
file_put_contents($package.'/.github/workflows/check-subtree-split.yml', <<<EOTXT
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:
{$mainRepo}
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"
});
}
EOTXT
);
}
26 changes: 26 additions & 0 deletions .github/workflows/package-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Verify Packages

on:
pull_request:
paths:
- src/**

permissions:
contents: read

jobs:
verify:
name: Verify Packages
runs-on: Ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Fetch branch from where the PR started
run: git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*

- name: Verify subtree-splits are auto-closed
run: |
php .github/sync-packages.php
git add src/
git diff --staged --exit-code || (echo '::error::Please run "php .github/sync-packages.php".' && exit 1)
3 changes: 1 addition & 2 deletions src/Autocomplete/.gitattributes
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/.symfony.bundle.yaml export-ignore
/assets/src export-ignore
/assets/test export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
/.git* export-ignore
6 changes: 6 additions & 0 deletions src/Autocomplete/.github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Please do not submit any Pull Requests here. They will be closed.
---
Please submit your PR here instead:
https://github.com/symfony/ux
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!
31 changes: 31 additions & 0 deletions src/Autocomplete/.github/workflows/check-subtree-split.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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/ux
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"
});
}
3 changes: 1 addition & 2 deletions src/Chartjs/.gitattributes
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/.symfony.bundle.yaml export-ignore
/assets/src export-ignore
/assets/test export-ignore
/assets/vitest.config.js export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
/.git* export-ignore
6 changes: 6 additions & 0 deletions src/Chartjs/.github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Please do not submit any Pull Requests here. They will be closed.
---
Please submit your PR here instead:
https://github.com/symfony/ux
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!
31 changes: 31 additions & 0 deletions src/Chartjs/.github/workflows/check-subtree-split.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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/ux
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"
});
}
3 changes: 1 addition & 2 deletions src/Cropperjs/.gitattributes
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/.symfony.bundle.yaml export-ignore
/assets/src export-ignore
/assets/test export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
/.git* export-ignore
6 changes: 6 additions & 0 deletions src/Cropperjs/.github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Please do not submit any Pull Requests here. They will be closed.
---
Please submit your PR here instead:
https://github.com/symfony/ux
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!
31 changes: 31 additions & 0 deletions src/Cropperjs/.github/workflows/check-subtree-split.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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/ux
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"
});
}
3 changes: 1 addition & 2 deletions src/Dropzone/.gitattributes
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/.symfony.bundle.yaml export-ignore
/assets/src export-ignore
/assets/test export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
/.git* export-ignore
6 changes: 6 additions & 0 deletions src/Dropzone/.github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Please do not submit any Pull Requests here. They will be closed.
---
Please submit your PR here instead:
https://github.com/symfony/ux
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!
31 changes: 31 additions & 0 deletions src/Dropzone/.github/workflows/check-subtree-split.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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/ux
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"
});
}
3 changes: 1 addition & 2 deletions src/Icons/.gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/.symfony.bundle.yaml export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
/.git* export-ignore
6 changes: 6 additions & 0 deletions src/Icons/.github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Please do not submit any Pull Requests here. They will be closed.
---
Please submit your PR here instead:
https://github.com/symfony/ux
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!
31 changes: 31 additions & 0 deletions src/Icons/.github/workflows/check-subtree-split.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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/ux
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"
});
}
3 changes: 1 addition & 2 deletions src/LazyImage/.gitattributes
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/.symfony.bundle.yaml export-ignore
/assets/src export-ignore
/assets/test export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
/.git* export-ignore
6 changes: 6 additions & 0 deletions src/LazyImage/.github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Please do not submit any Pull Requests here. They will be closed.
---
Please submit your PR here instead:
https://github.com/symfony/ux
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!
31 changes: 31 additions & 0 deletions src/LazyImage/.github/workflows/check-subtree-split.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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/ux
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"
});
}
Loading
Loading