Skip to content

Commit

Permalink
feat : github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Puskar-Roy committed Jul 13, 2024
1 parent 1fe5550 commit dd8dac0
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 🎯 Title and Issue Number

<!-- Please make sure issue number is mentioned in the Pull Request else PR will not be merged. -->

### Closes #<issue_no>

<!-- Replace `issue_no` with the issue number which is fixed in this PR -->

# 🗒️ Checklist:

- [ ] I have mentioned the issue number in my Pull Request.
- [ ] I have gone through `rules of when PR will get merged.`
- [ ] I have commented my code, particularly in hard-to-understand areas.
- [ ] I have created a helpful and easy-to-understand `README.md`.
- [ ] I have followed the proper file structure.
- [ ] I have gone through the repository guidelines.

Thank you for contributing! ❤️

Don't forget to show some support by ⭐ the repository!
25 changes: 25 additions & 0 deletions .github/workflows/closeIssue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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.MY_SEC }}
script: |
const { owner, repo, number } = context.issue;
const commentauthor = context.payload.issue.user.login;
const commentBody = `Hello @${commentauthor}! We'd like to inform you that the issue has been resolved and is now closed. We appreciate your understanding and look forward to your continued involvement with our repository!🤗
If you encounter any further issues, please don't hesitate to reach out to us on [LinkedIn](https://www.linkedin.com/in/puskar-roy/). Thank you for your support!❣️
Happy coding!✨ We hope to see you again soon!❣️
`;
await github.issues.createComment({ owner, repo, issue_number: number, body: commentBody });
console.log(`Commented on the issue: ${commentBody}.`);
26 changes: 26 additions & 0 deletions .github/workflows/issueOpen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Issue Opening Comment!
on:
issues:
types:
- opened

jobs:
comment:
runs-on: ubuntu-latest

steps:
- name: Issue Opened
uses: actions/github-script@v4
with:
github-token: ${{ secrets.MY_SEC }}
script: |
const { owner, repo, number } = context.issue;
const commentAuthor = context.payload.issue.user.login;
const commentBody = `Hey @${commentAuthor}👋! Thanks for raising this issue and demonstrating your interest in contributing to our project!🚀
We value your engagement and eagerly anticipate your contributions. Should you wish to get involved, please use the /assignme command to self-assign the issue.
This issue provides an excellent opportunity for us to enhance our project, and we're excited to have you join us! Please take a moment to review our [CONTRIBUTING GUIDELINES](../blob/master/CONTRIBUTING.md) before getting started.
If you have any questions or need assistance, feel free to reach out to us on [LinkedIn](https://www.linkedin.com/in/puskar-roy/).❤️
`;
await github.issues.createComment({ owner, repo, issue_number: number, body: commentBody });
console.log(`Commented on the issue: ${commentBody}.`);
50 changes: 50 additions & 0 deletions .github/workflows/prMerged.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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.MY_SEC }}
script: |
const { owner, repo, number } = context.issue;
const commentAuthor = context.payload.pull_request.user.login;
const commentBody = `
Hey @${commentAuthor}! We're excited to let you know that your pull request has been merged into the APIverse🚀🎁
Your commitment, effort, and expertise have greatly influenced our project, and we're incredibly thankful for your contributions.😇
Your code is now part of our expanding ecosystem, assisting developers worldwide in creating exceptional APIs.❣️🔥
Happy Coding! ✨ We look forward to seeing you again 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.MY_SEC }}
script: |
const { owner, repo, number } = context.issue;
const commentAuthor = context.payload.pull_request.user.login;
const commentBody = `Hey @${commentAuthor}, I wanted to inform you that we've decided to close your pull request.🙇
If you have any questions or need assistance, please don't hesitate to reach out to us on Discord.
Thank you for your understanding!❣️
Happy coding! ✨ We hope to see you again soon!❣️
`);
23 changes: 23 additions & 0 deletions .github/workflows/prOpen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Pull Request Welcome Comment
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.MY_SEC }}
script: |
const { owner, repo, number } = context.issue;
const author = context.payload.sender.login;
const commentBody = `Hello @${ author }, thank you for your pull request! We will review it shortly. 😇❣️
Your contributions help us grow and improve our project. Please make sure you have read and followed our [CONTRIBUTING GUIDELINES](../blob/master/CONTRIBUTING.md).
Your efforts are appreciated, and we value your participation in our community. Don't forget to ⭐ our repository!
Happy coding!✨`;
await github.issues.createComment({ owner, repo, issue_number: number, body: commentBody });
console.log('Commented on PR');
59 changes: 59 additions & 0 deletions .github/workflows/selfAssign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Self Assign Issue
on:
issue_comment:
types:
- created

jobs:
assign:
runs-on: ubuntu-latest
steps:
- name: Check for command
id: find_command
uses: actions/github-script@v4
with:
github-token: ${{secrets.My_SEC}}
script: |
const commentBody = context.payload.comment.body;
const assignUsing = '/assignme';
const isCommandPresent = commentBody.includes(assignUsing);
const commenter = context.payload.comment.user.login;
const isSelf = commenter === 'Puskar-Roy';
const hasAssignees = context.payload.issue.assignees.length > 0;
console.log(`Comment Body: ${commentBody}`);
console.log(`Command Present: ${isCommandPresent}`);
console.log(`Commenter: ${commenter}`);
console.log(`Is Self: ${isSelf}`);
console.log(`Assignees: ${context.payload.issue.assignees.map(assignee => assignee.login)}`);
if (isCommandPresent && isSelf) {
console.log('Command present in comment by self, ignoring');
console.log('::set-output name=toAssign::false');
} else if (isCommandPresent && hasAssignees) {
console.log('Command present, issue already assigned');
const { owner, repo, number } = context.issue;
const commentBody = `Hey @${commenter}, the issue has already been assigned and cannot be assigned to you again. Feel free to work on another issue or create a new one.😥
`;
github.issues.createComment({ owner, repo, issue_number: number, body: commentBody });
console.log('::set-output name=toAssign::false');
} else if (isCommandPresent) {
console.log('Command present, assigning the issue');
console.log('::set-output name=toAssign::true');
} else {
console.log('Command not present, nothing to do');
console.log('::set-output name=toAssign::false');
}
- name: Assign the issue
if: steps.find_command.outputs.toAssign == 'true'
id: assign_issue
uses: actions/github-script@v4
with:
github-token: ${{ secrets.MY_SEC}}
script: |
const { owner, repo, number } = context.issue;
const assignee = context.payload.comment.user.login;
await github.issues.addAssignees({ owner, repo, issue_number: number, assignees: [assignee] });
console.log(`Assigned the issue to ${assignee}.`);

0 comments on commit dd8dac0

Please sign in to comment.