Skip to content

Commit 829aa3c

Browse files
Allow closing issues via github actions (#4515)
- **PR Description** As discussed, this'll allow @ChrisMcD1 to clean up any issues that have already been resolved. Basically if you want to close an issue just leave a comment saying '/close'. Tested this over in my [OK?](https://github.com/jesseduffield/OK) and works like a charm. - **Please check if the PR fulfills these requirements** * [ ] Cheatsheets are up-to-date (run `go generate ./...`) * [ ] Code has been formatted (see [here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting)) * [ ] Tests have been added/updated (see [here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md) for the integration test guide) * [ ] Text is internationalised (see [here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation)) * [ ] If a new UserConfig entry was added, make sure it can be hot-reloaded (see [here](https://github.com/jesseduffield/lazygit/blob/master/docs/dev/Codebase_Guide.md#using-userconfig)) * [ ] Docs have been updated if necessary * [ ] You've read through your own file changes for silly mistakes etc <!-- Be sure to name your PR with an imperative e.g. 'Add worktrees view' see https://github.com/jesseduffield/lazygit/releases/tag/v0.40.0 for examples -->
2 parents 2b43f5b + b353d2a commit 829aa3c

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)