14
14
types :
15
15
- created
16
16
17
+ env :
18
+ BOUNTY_PROGRAM_LABELS_JSON : |
19
+ [
20
+ {"name": "bounty", "color": "0e8a16", "description": "Participation in the Bounty Program"}
21
+ ]
22
+
17
23
jobs :
18
24
guard-against-unauthorized-use :
19
25
if : >
20
26
github.actor != ('aeworxet' || 'thulieblack') &&
21
27
(
22
- contains (github.event.comment.body, '/bounty' )
28
+ startsWith (github.event.comment.body, '/bounty' )
23
29
)
24
30
25
31
runs-on : ubuntu-latest
@@ -46,15 +52,10 @@ jobs:
46
52
if : >
47
53
github.actor == ('aeworxet' || 'thulieblack') &&
48
54
(
49
- contains (github.event.comment.body, '/bounty' )
55
+ startsWith (github.event.comment.body, '/bounty' )
50
56
)
51
57
52
58
runs-on : ubuntu-latest
53
- env :
54
- BOUNTY_PROGRAM_LABELS_JSON : |
55
- [
56
- {"name": "bounty", "color": "0e8a16", "description": "Participation in the Bounty Program"}
57
- ]
58
59
59
60
steps :
60
61
- name : Add label `bounty`
88
89
repo: context.repo.repo,
89
90
labels: [BOUNTY_PROGRAM_LABELS[0].name]
90
91
})
92
+
93
+ remove-label-bounty :
94
+ if : >
95
+ github.actor == ('aeworxet' || 'thulieblack') &&
96
+ (
97
+ startsWith(github.event.comment.body, '/unbounty' )
98
+ )
99
+
100
+ runs-on : ubuntu-latest
101
+
102
+ steps :
103
+ - name : Remove label `bounty`
104
+ uses : actions/github-script@v6
105
+
106
+ with :
107
+ github-token : ${{ secrets.GH_TOKEN }}
108
+ script : |
109
+ const BOUNTY_PROGRAM_LABELS = JSON.parse(process.env.BOUNTY_PROGRAM_LABELS_JSON);
110
+ let LIST_OF_LABELS_FOR_ISSUE = await github.rest.issues.listLabelsOnIssue({
111
+ owner: context.repo.owner,
112
+ repo: context.repo.repo,
113
+ issue_number: context.issue.number,
114
+ });
115
+
116
+ LIST_OF_LABELS_FOR_ISSUE = LIST_OF_LABELS_FOR_ISSUE.data.map(key => key.name);
117
+
118
+ if (LIST_OF_LABELS_FOR_ISSUE.includes(BOUNTY_PROGRAM_LABELS[0].name)) {
119
+ console.log('Removing label `bounty`...');
120
+ github.rest.issues.removeLabel({
121
+ issue_number: context.issue.number,
122
+ owner: context.repo.owner,
123
+ repo: context.repo.repo,
124
+ name: [BOUNTY_PROGRAM_LABELS[0].name]
125
+ })
126
+ }
0 commit comments