-
-
Notifications
You must be signed in to change notification settings - Fork 49
77 lines (67 loc) · 2.86 KB
/
issue-commented.yml
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
66
67
68
69
70
71
72
73
74
75
76
77
name: On Issue Commented
on:
issue_comment:
types: [created]
jobs:
issue_tracked:
name: Issue tracked
if: ${{ !github.event.issue.pull_request }}
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Check command
shell: pwsh
run: |
$content = $env:CONTENT
$number = $env:NUMBER
$author = $env:Author
$role = $env:ROLE
echo "Content: $content"
echo "Issue: #$number"
echo "Author: $author"
echo "Role: $role"
if ($content -match '^Tracking #(\d*) .$') {
if (($role -eq "MEMBER") -or ($role -eq "OWNER")) {
$tracked = $Matches.1
echo "Tracked: #$tracked"
echo "Tracker: #$tracker"
echo "tracked_issue_number=$tracked" >> $env:GITHUB_ENV
echo "tracker_issue_number=$number" >> $env:GITHUB_ENV
echo "response=tracked" >> $env:GITHUB_ENV
} else {
echo "response=no-permission" >> $env:GITHUB_ENV
}
} else {
echo "response=false" >> $env:GITHUB_ENV
}
env:
NUMBER: ${{ github.event.issue.number }}
CONTENT: ${{ github.event.comment.body }}
AUTHOR: ${{ github.event.sender.login }}
ROLE: ${{ github.event.comment.author_association }}
- name: Add tracked comment
if: ${{ env.response == 'tracked' }}
uses: peter-evans/create-or-update-comment@a35cf36e5301d70b76f316e867e7788a55a31dae
with:
issue-number: ${{ env.tracked_issue_number }}
body: |
Tracked by #${{ env.tracker_issue_number }} .
- name: Add tracking label
if: ${{ env.response == 'tracked' }}
uses: actions/github-script@v6
with:
script: |
github.rest.issues.addLabels({
issue_number: ${{ env.tracked_issue_number }},
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["tracking"]
})
- name: Add no permission comment
if: ${{ env.response == 'no-permission' }}
uses: peter-evans/create-or-update-comment@a35cf36e5301d70b76f316e867e7788a55a31dae
with:
issue-number: ${{ github.event.issue.number }}
body: |
@${{ github.event.sender.login }}, You have no permission to run this command .