diff --git a/.github/workflows/autoComment.yaml b/.github/workflows/autoComment.yaml index 6d6ce99..e6aa51d 100644 --- a/.github/workflows/autoComment.yaml +++ b/.github/workflows/autoComment.yaml @@ -4,7 +4,8 @@ on: issues: types: [opened] pull_request: - types: [opened] + types: + - opened jobs: auto-comment: @@ -13,17 +14,94 @@ jobs: issues: write pull-requests: write steps: - - name: Auto Comment - uses: actions/github-script@v7 + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Add Comment on Pull Request + if: ${{ github.event_name == 'pull_request' }} + uses: actions/github-script@v6 with: - github-token: ${{secrets.GITHUB_TOKEN}} + github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const issueComment = context.payload.issue - ? `Thank you for opening an issue, @${context.payload.issue.user.login}! will review it soon. Meanwhile you can describe & share your approach on how to resolve this issue.` - : `Thank you for creating this pull request, @${context.payload.pull_request.user.login}! A reviewer will check it shortly.`; - github.rest.issues.createComment({ + const issueNumber = context.issue.number; + const contributor = context.issue.pull_request.user.login; + const relatedIssue = context.issue.pull_request.issue.number; + + const commentBody = `🚀 **Hello @${contributor}!** + + Thank you for your contribution to the **Leetcode Journal** project! 🎉 + We value your effort and are excited to review your changes. + + **PR Details:** + + * **Contributor:** @${contributor} + * **Related Issue:** Closes #${relatedIssue} (if applicable) + + ### PR Checklist: + Please ensure your PR adheres to the following checklist: + - [ ] PR description includes a summary and context for the changes. + - [ ] Relevant dependencies have been listed. + - [ ] Testing section is filled out with details on verification. + - [ ] Screenshots/Videos are attached (if applicable). + - [ ] Checklist items are marked as completed. + + ### Review Notifications: + - **Project Admin:** @yashksaini-coder + - **Mentor:** @ompharate + + The team will review your PR shortly. If you have any questions, feel free to ask here! + Happy Coding! 🚀 + + const params = { owner: context.repo.owner, repo: context.repo.repo, - issue_number: context.issue.number, - body: issueComment, - }); + issue_number: issueNumber, + body: commentBody + }; + + github.rest.issues.createComment(params); + + - name: Add Comment on Issue + if: ${{ github.event_name == 'issues' }} + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const issueNumber = context.issue.number; + const contributor = context.issue.user.login; + + const commentBody = `👋 **Hello @${contributor}!** + + Thank you for raising an issue in the **Leetcode Journal** project! + Your issue has been logged, and the team will review it shortly. + + **Issue Details:** + + * **Contributor:** @${contributor} + + ### Issue Handling Checklist: + - [ ] Make sure the issue includes clear steps to reproduce (if applicable). + - [ ] Provide relevant context, screenshots, or logs. + - [ ] Mention if this issue blocks any critical workflows. + - [ ] **If it's a Feature Request:** + * Explain the desired functionality, including: + * Approach: How you envision implementing this feature. + * Benefits: How this feature will improve the project. + - [ ] **If it's a Bug:** + * Describe how to resolve it without affecting the working of the project. + + + ### Notifications: + - **Project Admin:** @yashksaini-coder + - **Mentor:** @ompharate + + We'll get back to you soon. Stay tuned! 🚀 + + const params = { + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issueNumber, + body: commentBody + }; + + github.rest.issues.createComment(params);