Skip to content

Commit 1396e28

Browse files
authored
feat(tools): autoclose unauthorised spec PRs (#48)
1 parent 9208cb1 commit 1396e28

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

.github/workflows/autoclose.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Autoclose PRs
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'asyncapi.yml'
7+
- 'openapi.yml'
8+
9+
jobs:
10+
autoclose:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/github-script@v6
14+
with:
15+
github-token: ${{secrets.GITHUB_TOKEN}}
16+
script |
17+
const creator = context.payload.sender.login;
18+
const allowedUsers = ["deepgram-robot"];
19+
if (allowedUsers.includes(creator)) {
20+
return;
21+
}
22+
core.setFailed("Invalid PR detected.");
23+
github.rest.issues.createComment({
24+
issue_number: context.issue.number,
25+
owner: context.repo.owner,
26+
repo: context.repo.repo,
27+
body: "Thank you for opening this pull request.\n\nThis is a standard message notifying you that the API specification files should not be edited by a human. These are automatically generated through our various tooling."
28+
});
29+
github.rest.pulls.update({
30+
owner: context.payload.repository.owner.login,
31+
repo: context.payload.repository.name,
32+
pull_number: context.payload.pull_request.number,
33+
state: "closed"
34+
});

0 commit comments

Comments
 (0)