Assign Issue to Self #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Assign Issue to Self | |
on: | |
issue_comment: | |
types: [created] | |
permissions: | |
issues: write # Ensure the workflow has write permissions for issues | |
jobs: | |
assign: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Assign issue to commenter if they comment "self" | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const issueNumber = context.issue.number; | |
const commentBody = context.payload.comment.body.trim().toLowerCase(); | |
const commenter = context.payload.comment.user.login; | |
if (commentBody === 'self') { | |
await github.rest.issues.addAssignees({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issueNumber, | |
assignees: [commenter] | |
}); | |
} |