Skip to content

Commit

Permalink
Create self-assign.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
MohanRamSridhar authored May 30, 2024
1 parent 1dcc5bd commit afea7ea
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/self-assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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]
});
}

0 comments on commit afea7ea

Please sign in to comment.