-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto comment on an issue and self assign the issue (#127)
* Update and rename greetings.yaml to auto-comment.yml * Create self-assign.yml
- Loading branch information
1 parent
7b7212e
commit 879c4cc
Showing
3 changed files
with
52 additions
and
16 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Comment on opening issue! | ||
on: | ||
issues: | ||
types: | ||
- opened | ||
|
||
jobs: | ||
comment: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Issue Opened | ||
uses: actions/github-script@v4 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const { owner, repo, number } = context.issue; | ||
const commentauthor = context.payload.issue.user.login; | ||
const commentBody = `Hello @${commentauthor} Thank you for creating a new issue! 🎉 Your issue is currently under review.\nIf you would like to assign this issue to yourself, please comment with the word "self" and the issue will be assigned to you.`; | ||
await github.issues.createComment({ owner, repo, issue_number: number, body: commentBody }); | ||
console.log(`Commented on the issue: ${commentBody}.`); |
This file was deleted.
Oops, something went wrong.
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
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] | ||
}); | ||
} |