-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from MohanRamSridhar/main
Auto comment on issue and self assign the issue
- Loading branch information
Showing
6 changed files
with
138 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: Close issue comment | ||
on: | ||
issues: | ||
types: | ||
- closed | ||
|
||
jobs: | ||
comment: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Issue close | ||
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 = `Hey @${commentauthor} ! Just wanted to inform you that the issue has been closed\nWould like to see you again.`; | ||
await github.issues.createComment({ owner, repo, issue_number: number, body: commentBody }); | ||
console.log(`Commented on the issue: ${commentBody}.`); |
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,41 @@ | ||
name: Comment on PR Closure | ||
|
||
on: | ||
pull_request_target: | ||
types: | ||
- closed | ||
|
||
jobs: | ||
comment: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check PR Merge Status | ||
id: pr_status | ||
run: echo "::set-output name=merged::${{ github.event.pull_request.merged }}" | ||
|
||
- name: Comment on PR Closure | ||
if: steps.pr_status.outputs.merged == 'true' | ||
uses: actions/github-script@v4 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const { owner, repo, number } = context.issue; | ||
const commentAuthor = context.payload.pull_request.user.login; | ||
const commentBody = `Hey @${ commentAuthor } Super Happy to inform you that your PR has been merged!!!!!!\nWould like to see you again super soon.`; | ||
await github.issues.createComment({ owner, repo, issue_number: number, body: commentBody }); | ||
console.log(`Commented on the closed PR: ${commentBody}.`); | ||
- name: Comment on PR Closure | ||
if: steps.pr_status.outputs.merged != 'true' | ||
uses: actions/github-script@v4 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const { owner, repo, number } = context.issue; | ||
const commentAuthor = context.payload.pull_request.user.login; | ||
const commentBody = `Hey @${ commentAuthor } ,Wanted to let you know that we have decided to close your pull request. | ||
In case of any issues, you can contact me. | ||
Thank you!`; | ||
await github.issues.createComment({ owner, repo, issue_number: number, body: commentBody }); | ||
console.log(`Commented on the closed PR: ${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,23 @@ | ||
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 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: Pull Request related comments | ||
on: | ||
pull_request_target: | ||
types: | ||
- opened | ||
|
||
jobs: | ||
comment: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Comment on Opening Pull Request | ||
uses: actions/github-script@v4 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const {owner, repo, number} = context.issue; | ||
const commentAuthor = context.payload.sender.login; | ||
const commentBody = `Hey @${ commentAuthor }, Thank you for creating PR! Will review it super soon. | ||
Don’t forget to ⭐ the repository! | ||
Will see you soon!`; | ||
await github.issues.createComment({owner, repo, issue_number : number, body: commentBody}); | ||
console.log('Commented on PR'); |
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] | ||
}); | ||
} |