chore: import upstream snapshot with attribution
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
name: GitHub - Autoclose Invalid PRs
|
||||
on:
|
||||
pull_request_target:
|
||||
branches:
|
||||
- 'main'
|
||||
paths:
|
||||
- '.gitignore'
|
||||
|
||||
jobs:
|
||||
autoclose:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
|
||||
with:
|
||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||
script: |
|
||||
const files = await github.rest.pulls.listFiles({
|
||||
owner: context.payload.repository.owner.login,
|
||||
repo: context.payload.repository.name,
|
||||
pull_number: context.payload.pull_request.number,
|
||||
});
|
||||
if (
|
||||
files.data.length !== 1 ||
|
||||
(files.data[0].filename !== ".gitignore" &&
|
||||
// We've had four PRs make this same (irrelevant) change already.
|
||||
!(files.data[0].filename === "664ef4623946e65e18d59764.md" &&
|
||||
files.data[0].patch.includes("return re.sub('(?<!\d)1', '', equation_string.strip('+'))")
|
||||
)
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const creator = context.payload.sender.login;
|
||||
const opts = github.rest.issues.listForRepo.endpoint.merge({
|
||||
...context.issue,
|
||||
creator,
|
||||
state: 'all'
|
||||
});
|
||||
const issues = await github.paginate(opts);
|
||||
|
||||
// iterate through issues
|
||||
for (const issue of issues) {
|
||||
// if the issue is this one, keep looking
|
||||
if (issue.number === context.issue.number) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// if the issue is actually a PR, they're not a first timer
|
||||
if (issue.pull_request) {
|
||||
return // Creator is already a contributor.
|
||||
}
|
||||
}
|
||||
core.setFailed("Invalid PR detected.");
|
||||
await github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: "Thank you for opening this pull request.\n\nThis is a standard message notifying you that we've reviewed your pull request and have decided not to merge it. We would welcome future pull requests from you.\n\nThank you and happy coding.",
|
||||
});
|
||||
await github.rest.pulls.update({
|
||||
owner: context.payload.repository.owner.login,
|
||||
repo: context.payload.repository.name,
|
||||
pull_number: context.payload.pull_request.number,
|
||||
state: "closed"
|
||||
});
|
||||
await github.rest.issues.addLabels({
|
||||
owner: context.payload.repository.owner.login,
|
||||
repo: context.payload.repository.name,
|
||||
issue_number: context.issue.number,
|
||||
labels: ["spam"]
|
||||
});
|
||||
Reference in New Issue
Block a user