From 9966ac1d942a158160ca30a049eb3318d610aad3 Mon Sep 17 00:00:00 2001 From: Mohan Ram Sridhar <142170808+MohanRamSridhar@users.noreply.github.com> Date: Thu, 30 May 2024 09:56:37 +0530 Subject: [PATCH 1/9] Create closed-issue.yml this Willa auto comment when the issue is closed --- .github/workflows/closed-issue.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/closed-issue.yml diff --git a/.github/workflows/closed-issue.yml b/.github/workflows/closed-issue.yml new file mode 100644 index 0000000..6b78642 --- /dev/null +++ b/.github/workflows/closed-issue.yml @@ -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}.`); From a59ec0b69fd3587d6fdffc70d0cf06c21af9fd3f Mon Sep 17 00:00:00 2001 From: Mohan Ram Sridhar <142170808+MohanRamSridhar@users.noreply.github.com> Date: Thu, 30 May 2024 09:57:45 +0530 Subject: [PATCH 2/9] Create closed-pr.yml this will auto comment when an pr is closed based on if it is merged and closed or closed due to some other reason --- .github/workflows/closed-pr.yml | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/closed-pr.yml diff --git a/.github/workflows/closed-pr.yml b/.github/workflows/closed-pr.yml new file mode 100644 index 0000000..4b5b257 --- /dev/null +++ b/.github/workflows/closed-pr.yml @@ -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.PAT }} + 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.PAT }} + 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}.`); From 3729eafedb6cf6faed41c042524bc44c5fd04e32 Mon Sep 17 00:00:00 2001 From: Mohan Ram Sridhar <142170808+MohanRamSridhar@users.noreply.github.com> Date: Thu, 30 May 2024 09:58:33 +0530 Subject: [PATCH 3/9] Create pr-review.yml this will send a message that the pr is under review --- .github/workflows/pr-review.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/pr-review.yml diff --git a/.github/workflows/pr-review.yml b/.github/workflows/pr-review.yml new file mode 100644 index 0000000..e63a3ba --- /dev/null +++ b/.github/workflows/pr-review.yml @@ -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.PAT }} + 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'); From a49b422aa63d49a5e06c374ecc35b188501b2a9a Mon Sep 17 00:00:00 2001 From: Mohan Ram Sridhar <142170808+MohanRamSridhar@users.noreply.github.com> Date: Thu, 30 May 2024 09:59:07 +0530 Subject: [PATCH 4/9] Update closed-pr.yml changed PAT to GITHUB_TOKEN --- .github/workflows/closed-pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/closed-pr.yml b/.github/workflows/closed-pr.yml index 4b5b257..b61a191 100644 --- a/.github/workflows/closed-pr.yml +++ b/.github/workflows/closed-pr.yml @@ -18,7 +18,7 @@ jobs: if: steps.pr_status.outputs.merged == 'true' uses: actions/github-script@v4 with: - github-token: ${{ secrets.PAT }} + github-token: ${{ secrets.GITHUB_TOKEN }} script: | const { owner, repo, number } = context.issue; const commentAuthor = context.payload.pull_request.user.login; @@ -30,7 +30,7 @@ jobs: if: steps.pr_status.outputs.merged != 'true' uses: actions/github-script@v4 with: - github-token: ${{ secrets.PAT }} + github-token: ${{ secrets.GITHUB_TOKEN }} script: | const { owner, repo, number } = context.issue; const commentAuthor = context.payload.pull_request.user.login; From 6dab550690a7f2e97428084ca73cfd4a54e2ccc4 Mon Sep 17 00:00:00 2001 From: Mohan Ram Sridhar <142170808+MohanRamSridhar@users.noreply.github.com> Date: Thu, 30 May 2024 09:59:34 +0530 Subject: [PATCH 5/9] Update pr-review.yml changed PAT to GITHUB_TOKEN --- .github/workflows/pr-review.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-review.yml b/.github/workflows/pr-review.yml index e63a3ba..19270db 100644 --- a/.github/workflows/pr-review.yml +++ b/.github/workflows/pr-review.yml @@ -11,7 +11,7 @@ jobs: - name: Comment on Opening Pull Request uses: actions/github-script@v4 with: - github-token: ${{ secrets.PAT }} + github-token: ${{ secrets.GITHUB_TOKEN }} script: | const {owner, repo, number} = context.issue; const commentAuthor = context.payload.sender.login; From 41c9b60cd9ba65e05c8d573b55d2da33699883a5 Mon Sep 17 00:00:00 2001 From: Mohan Ram Sridhar <142170808+MohanRamSridhar@users.noreply.github.com> Date: Thu, 30 May 2024 10:00:16 +0530 Subject: [PATCH 6/9] Delete .github/workflows/greetings.yaml deleted this greeting.yml and made separate files for every purpose --- .github/workflows/greetings.yaml | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 .github/workflows/greetings.yaml diff --git a/.github/workflows/greetings.yaml b/.github/workflows/greetings.yaml deleted file mode 100644 index 704db0e..0000000 --- a/.github/workflows/greetings.yaml +++ /dev/null @@ -1,16 +0,0 @@ -name: Greetings - -on: [pull_request_target, issues] - -jobs: - greeting: - runs-on: ubuntu-latest - permissions: - issues: write - pull-requests: write - steps: - - uses: actions/first-interaction@v1 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - issue-message: "Hi there! Thanks for opening this issue. We appreciate your contribution to this open-source project. We aim to respond or assign your issue as soon as possible." - pr-message: "Welcome to Our repository.🎊 Thank you so much for taking the time to point this out." From 8f12c3945959f9fe45bc8c0fcfbbf475bbb5084a Mon Sep 17 00:00:00 2001 From: Mohan Ram Sridhar <142170808+MohanRamSridhar@users.noreply.github.com> Date: Thu, 30 May 2024 10:01:25 +0530 Subject: [PATCH 7/9] Create issue-comment.yml this will be a replacement for the greetings.yml --- .github/workflows/issue-comment.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/issue-comment.yml diff --git a/.github/workflows/issue-comment.yml b/.github/workflows/issue-comment.yml new file mode 100644 index 0000000..beac3c8 --- /dev/null +++ b/.github/workflows/issue-comment.yml @@ -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.PAT }} + 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}.`); + From 1dcc5bd2faf48a65fe44b092f03817640c3bc914 Mon Sep 17 00:00:00 2001 From: Mohan Ram Sridhar <142170808+MohanRamSridhar@users.noreply.github.com> Date: Thu, 30 May 2024 10:02:23 +0530 Subject: [PATCH 8/9] Update issue-comment.yml --- .github/workflows/issue-comment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/issue-comment.yml b/.github/workflows/issue-comment.yml index beac3c8..88a4f8e 100644 --- a/.github/workflows/issue-comment.yml +++ b/.github/workflows/issue-comment.yml @@ -12,7 +12,7 @@ jobs: - name: Issue Opened uses: actions/github-script@v4 with: - github-token: ${{ secrets.PAT }} + github-token: ${{ secrets.GITHUB_TOKEN }} script: | const { owner, repo, number } = context.issue; const commentauthor = context.payload.issue.user.login; From afea7ea770983a11cfbaf442caf440b3a8151e26 Mon Sep 17 00:00:00 2001 From: Mohan Ram Sridhar <142170808+MohanRamSridhar@users.noreply.github.com> Date: Thu, 30 May 2024 10:03:46 +0530 Subject: [PATCH 9/9] Create self-assign.yml --- .github/workflows/self-assign.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/self-assign.yml diff --git a/.github/workflows/self-assign.yml b/.github/workflows/self-assign.yml new file mode 100644 index 0000000..6381cea --- /dev/null +++ b/.github/workflows/self-assign.yml @@ -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] + }); + }