Skip to content

Commit

Permalink
Added self assign issue workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dishamodi0910 committed Sep 27, 2023
1 parent 02e31f6 commit 2f8e279
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/issue_open_greet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
script: |
const { owner, repo, number } = context.issue;
const commentauthor = context.payload.issue.user.login;
const commentBody = `Greetings @${commentauthor}🎀 ! , We are excited to have you dive into another issue with us!🚀\nYour involvement in our project has been invaluable, and we're confident that your skills and insights will help us conquer this challenge😇. This issue represents an exciting opportunity for us to improve and enhance our project, and we are thrilled to have you on board.\n We request you to follow [CONTRIBUTING GUIDELINES](../blob/master/CONTRIBUTING.md).\nLooking for your PR soon! \n In case of any issues, you can contact us on [Discord](https://discord.gg/mv4NTzN).❣️`;
const commentBody = `Greetings @${commentauthor}🎀 ! , We are excited to have you dive into another issue with us!🚀\nYour involvement in our project has been invaluable, and we're confident that your skills and insights will help us conquer this challenge😇. <h2> Use command /gdsc to self assign the issue. </h2> This issue represents an exciting opportunity for us to improve and enhance our project, and we are thrilled to have you on board.\n We request you to follow [CONTRIBUTING GUIDELINES](../blob/master/CONTRIBUTING.md).\nLooking for your PR soon! \n In case of any issues, you can contact us on [Discord](https://discord.gg/mv4NTzN).❣️`;
await github.issues.createComment({ owner, repo, issue_number: number, body: commentBody });
console.log(`Commented on the issue: ${commentBody}.`);
Expand Down
75 changes: 75 additions & 0 deletions .github/workflows/self_assign_issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
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.APIVerse_SECRET}}
script: |
const commentbody = context.payload.comment.body;
const assignUsing = '/gdsc';
const isCommandPresent = commentbody.includes(assignUsing);
const commentor = context.payload.comment.user.login;
const Repoowner = context.payload.repository.owner.login;
console.log(`${Repoowner}`);
console.log(`${commentor}`);
const isSelf = commentor === context.payload.repository.owner.login;
console.log(`${isSelf}`);
console.log(`${context.payload.issue.assignees.map(assignee => assignee.login)}`);
const noOfAssignees = context.payload.issue.assignees.length>0;
console.log(`No of Assignees : ${noOfAssignees}`);
if(isCommandPresent && isSelf)
{
console.log('Instruction given to contributor comment, so ignore');
console.log(`::set-output name=toAssign::false`);
console.log(`Ins from repo owner end`);
}
else if(isCommandPresent && noOfAssignees)
{
console.log('Issue is already assigned');
const { owner,repo, number} = context.issue;
const commentbody = `Hey @${commentor}, The issue is already assigned and couldn't be assigned to you again.You can work on some other issue or create your own issue.🚀💗`;
github.issues.createComment({ owner, repo, issue_number: number, body: commentbody });
console.log(`::set-output name=toAssign::false`);
console.log('Command present and issue already assigned');
}
else if(isCommandPresent)
{
console.log(`::set-output name=toAssign::true`);
console.log('Command present and issue not assigned');
}
else
{
console.log(`::set-output name=toAssign::false`);
console.log('Command not present');
}
- name: Assign the issue
if: steps.find_command.outputs.toAssign == 'true'
id: assign_issue
uses: actions/github-script@v4
with:
github-token: ${{ secrets.APIVerse_SECRET}}
script: |
console.log('Demo Text');
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 2f8e279

Please sign in to comment.