Skip to content

Commit 87ac58c

Browse files
authored
ci: update of files from global .github repo (#1054)
1 parent eda8937 commit 87ac58c

File tree

1 file changed

+43
-7
lines changed

1 file changed

+43
-7
lines changed

.github/workflows/bounty-program-commands.yml

+43-7
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@ on:
1414
types:
1515
- created
1616

17+
env:
18+
BOUNTY_PROGRAM_LABELS_JSON: |
19+
[
20+
{"name": "bounty", "color": "0e8a16", "description": "Participation in the Bounty Program"}
21+
]
22+
1723
jobs:
1824
guard-against-unauthorized-use:
1925
if: >
2026
github.actor != ('aeworxet' || 'thulieblack') &&
2127
(
22-
contains(github.event.comment.body, '/bounty' )
28+
startsWith(github.event.comment.body, '/bounty' )
2329
)
2430
2531
runs-on: ubuntu-latest
@@ -46,15 +52,10 @@ jobs:
4652
if: >
4753
github.actor == ('aeworxet' || 'thulieblack') &&
4854
(
49-
contains(github.event.comment.body, '/bounty' )
55+
startsWith(github.event.comment.body, '/bounty' )
5056
)
5157
5258
runs-on: ubuntu-latest
53-
env:
54-
BOUNTY_PROGRAM_LABELS_JSON: |
55-
[
56-
{"name": "bounty", "color": "0e8a16", "description": "Participation in the Bounty Program"}
57-
]
5859

5960
steps:
6061
- name: Add label `bounty`
@@ -88,3 +89,38 @@ jobs:
8889
repo: context.repo.repo,
8990
labels: [BOUNTY_PROGRAM_LABELS[0].name]
9091
})
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

Comments
 (0)