Skip to content

Commit b353d2a

Browse files
committed
Allow closing issues via github actions
This provides some basic admin permissions without needing to go all the way up to a collaborator.
1 parent 2b43f5b commit b353d2a

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

.github/workflows/close-issues.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Close Issues
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
permissions:
8+
issues: write
9+
10+
jobs:
11+
close_issue:
12+
runs-on: ubuntu-latest
13+
if: ${{ github.event.issue.pull_request == null && startsWith(github.event.comment.body, '/close') }}
14+
steps:
15+
- uses: actions/github-script@v7
16+
with:
17+
script: |
18+
const trustedUsers = ['ChrisMcD1', 'jesseduffield', 'stefanhaller']
19+
const commenter = context.payload.comment.user.login
20+
21+
console.log(`Commenter: ${commenter}`)
22+
23+
if (!trustedUsers.includes(commenter)) {
24+
console.log(`User ${commenter} is not trusted. Ignoring.`)
25+
return
26+
}
27+
28+
const issueNumber = context.payload.issue.number
29+
const owner = context.repo.owner
30+
const repo = context.repo.repo
31+
32+
await github.rest.issues.update({
33+
owner,
34+
repo,
35+
issue_number: issueNumber,
36+
state: 'closed'
37+
})
38+
39+
console.log(`Closed issue #${issueNumber} by request from ${commenter}.`)

0 commit comments

Comments
 (0)