Skip to content

Allow closing issues via github actions #4515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/close-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Close Issues

on:
issue_comment:
types: [created]

permissions:
issues: write

jobs:
close_issue:
runs-on: ubuntu-latest
if: ${{ github.event.issue.pull_request == null && startsWith(github.event.comment.body, '/close') }}
steps:
- uses: actions/github-script@v7
with:
script: |
const trustedUsers = ['ChrisMcD1', 'jesseduffield', 'stefanhaller']
const commenter = context.payload.comment.user.login

console.log(`Commenter: ${commenter}`)

if (!trustedUsers.includes(commenter)) {
console.log(`User ${commenter} is not trusted. Ignoring.`)
return
}

const issueNumber = context.payload.issue.number
const owner = context.repo.owner
const repo = context.repo.repo

await github.rest.issues.update({
owner,
repo,
issue_number: issueNumber,
state: 'closed'
})

console.log(`Closed issue #${issueNumber} by request from ${commenter}.`)
Loading