-
Notifications
You must be signed in to change notification settings - Fork 30
53 lines (43 loc) · 1.41 KB
/
close.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# https://docs.github.com/en/actions
name: "Close"
on: # yamllint disable-line rule:truthy
pull_request_target:
types:
- "opened"
- "reopened"
jobs:
close:
name: "Close"
runs-on: "ubuntu-latest"
steps:
- name: "Close pull requests created by violinist-bot"
uses: "actions/github-script@v7"
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
script: |
const actors = [
"violinist-bot",
]
const pullRequest = context.payload.pull_request;
const repository = context.repo;
const actor = context.actor;
if (actors.includes(actor)) {
github.rest.issues.createComment({
body: "I'm sorry, @" + actor + ". I'm afraid you can't do that.",
issue_number: pullRequest.number,
owner: repository.owner,
repo: repository.repo,
});
github.rest.pulls.update({
owner: repository.owner,
pull_number: pullRequest.number,
repo: repository.repo,
state: "closed",
});
github.rest.issues.lock({
issue_number: pullRequest.number,
lock_reason: "off-topic",
owner: repository.owner,
repo: repository.repo,
});
}