feat(actions): autoclose workflow (#43644)
This commit is contained in:
committed by
GitHub
parent
d5e3979753
commit
d3beb6e370
41
.github/workflows/autoclose.yml
vendored
Normal file
41
.github/workflows/autoclose.yml
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
name: Autoclose
|
||||
on:
|
||||
pull_request_target:
|
||||
branches:
|
||||
- "main"
|
||||
paths:
|
||||
- ".gitignore"
|
||||
|
||||
jobs:
|
||||
autoclose:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/github-script@v5
|
||||
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" &&
|
||||
files.data[0].patch ===
|
||||
"@@ -63,7 +63,6 @@ $RECYCLE.BIN/\n # Icon must end with two \\r\n Icon\n \n-\n # Thumbnails\n ._*\n "
|
||||
) {
|
||||
core.setFailed("Invalid PR detected.");
|
||||
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"
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user