Skip to content

Add auto-assign-on-comment.yaml #14

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 25, 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
50 changes: 50 additions & 0 deletions .github/workflows/auto-assign-on-comment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Auto Assign on 'take' Comment
on:
issue_comment:
types: [created]
permissions:
issues: write
jobs:
assign:
runs-on: ubuntu-latest
if: (!github.event.issue.pull_request) && contains(github.event.comment.body, 'take')
concurrency:
group: ${{ github.actor }}-auto-assign-issue
cancel-in-progress: true
steps:
- name: Auto assign if comment includes 'take'
uses: actions/github-script@v7
with:
script: |
const body = context.payload.comment.body.toLowerCase();
const author = context.payload.comment.user.login;
const issue = context.payload.issue;
// Check if comment includes 'take'
if (!body.includes('take')) {
console.log("Comment does not include 'take'; skipping.");
return;
}
// Check if already assigned
const alreadyAssigned = issue.assignees.find(a => a.login === author);
if (alreadyAssigned) {
console.log(`${author} is already assigned; skipping.`);
return;
}
// Check if there is any other assignee
if (issue.assignees.length > 0) {
console.log("Issue already has an assignee; skipping assignment.");
return;
}
// Assign to commenter
await github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
assignees: [author],
});
console.log(`Assigned ${author} to issue #${issue.number}`);