-
-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (60 loc) · 2.98 KB
/
Copy paththis.yml
File metadata and controls
65 lines (60 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: Assign on Comment
on:
issue_comment:
types:
- created
jobs:
assign:
runs-on: ubuntu-latest
steps:
- name: Check if /assign command is present
id: check_command
uses: actions/github-script@v4
with:
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
script: |
const commentBody = context.payload.comment.body;
const assignCommand = '/assign';
const isCommandPresent = commentBody.includes(assignCommand);
console.log(`Command present: ${isCommandPresent}`);
console.log(`Comment: ${commentBody}`);
console.log(`Issue Number: ${context.payload.issue.number}`);
console.log(`Issue State: ${context.payload.issue.state}`);
console.log(`Assignees: ${context.payload.issue.assignees.map(assignee => assignee.login)}`);
console.log(`Issue URL: ${context.payload.issue.html_url}`);
console.log(`Comment URL: ${context.payload.comment.html_url}`);
console.log(`Comment Author: ${context.payload.comment.user.login}`);
console.log(`Repository: ${context.repo.owner}/${context.repo.repo}`);
console.log(`Repository URL: ${context.payload.repository.html_url}`);
console.log(`Repository Full Name: ${context.payload.repository.full_name}`);
console.log(`Repository Name: ${context.payload.repository.name}`);
console.log(`Repository Owner: ${context.payload.repository.owner.login}`);
console.log(`Repository Owner URL: ${context.payload.repository.owner.html_url}`);
console.log(`Event Name: ${context.eventName}`);
if (isCommandPresent) {
core.setOutput('assign_issue', true);
} else {
core.setOutput('assign_issue', false);
}
- name: Assign the issue
if: steps.check_command.outputs.assign_issue == 'true'
id: assign_issue
uses: actions/github-script@v4
with:
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
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}.`);
- name: Comment if issue is already assigned
if: steps.check_command.outputs.assign_issue == 'false' && contains(github.event.comment.body, '/assign')
id: comment_assigned
uses: actions/github-script@v4
with:
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
script: |
const { owner, repo, number } = context.issue;
const commentBody = 'This issue is already assigned.';
await github.issues.createComment({ owner, repo, issue_number: number, body: commentBody });
console.log(`Commented on the issue: ${commentBody}.`);