Skip to content
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

update Auto-Comment Workflow for Pull Requests and Issues as I got an error in previous PR #13

Closed
wants to merge 4 commits into from
Closed
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
100 changes: 89 additions & 11 deletions .github/workflows/autoComment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ on:
issues:
types: [opened]
pull_request:
types: [opened]
types:
- opened

jobs:
auto-comment:
Expand All @@ -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 }}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename GITHUB_TOKEN to GH_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);
Loading