Skip to content

Commit 89f67e9

Browse files
Planeshifterkgryte
andauthored
build: restrict slash commands to users with write access
PR-URL: #12341 Co-authored-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Athan Reines <kgryte@gmail.com> Signed-off-by: Athan Reines <kgryte@gmail.com>
1 parent 489a111 commit 89f67e9

1 file changed

Lines changed: 28 additions & 7 deletions

File tree

.github/workflows/slash_commands.yml

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ jobs:
9797
needs: [ add_initial_reaction ]
9898

9999
# Define the conditions under which the job should run:
100-
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/stdlib check-files')
100+
if: |
101+
github.event.issue.pull_request &&
102+
startsWith(github.event.comment.body, '/stdlib check-files') &&
103+
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)
101104
102105
# Run reusable workflow:
103106
uses: ./.github/workflows/check_required_files.yml
@@ -116,7 +119,10 @@ jobs:
116119
needs: [ add_initial_reaction ]
117120

118121
# Define the conditions under which the job should run:
119-
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/stdlib make-commands')
122+
if: |
123+
github.event.issue.pull_request &&
124+
startsWith(github.event.comment.body, '/stdlib make-commands') &&
125+
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)
120126
121127
# Run reusable workflow:
122128
uses: ./.github/workflows/pr_commands_comment.yml
@@ -132,7 +138,10 @@ jobs:
132138
name: 'Update copyright header years'
133139

134140
# Define the conditions under which the job should run:
135-
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/stdlib update-copyright-years')
141+
if: |
142+
github.event.issue.pull_request &&
143+
startsWith(github.event.comment.body, '/stdlib update-copyright-years') &&
144+
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)
136145
137146
# Run reusable workflow:
138147
uses: ./.github/workflows/update_pr_copyright_years.yml
@@ -153,7 +162,10 @@ jobs:
153162
needs: [ add_initial_reaction ]
154163

155164
# Define the conditions under which the job should run:
156-
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/stdlib lint-autofix')
165+
if: |
166+
github.event.issue.pull_request &&
167+
startsWith(github.event.comment.body, '/stdlib lint-autofix') &&
168+
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)
157169
158170
# Run reusable workflow:
159171
uses: ./.github/workflows/lint_autofix.yml
@@ -174,7 +186,10 @@ jobs:
174186
needs: [ add_initial_reaction ]
175187

176188
# Define the conditions under which the job should run:
177-
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/stdlib merge')
189+
if: |
190+
github.event.issue.pull_request &&
191+
startsWith(github.event.comment.body, '/stdlib merge') &&
192+
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)
178193
179194
# Run reusable workflow:
180195
uses: ./.github/workflows/pr_merge_develop.yml
@@ -195,7 +210,10 @@ jobs:
195210
needs: [ add_initial_reaction ]
196211

197212
# Define the conditions under which the job should run:
198-
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/stdlib rebase')
213+
if: |
214+
github.event.issue.pull_request &&
215+
startsWith(github.event.comment.body, '/stdlib rebase') &&
216+
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)
199217
200218
# Run reusable workflow:
201219
uses: ./.github/workflows/pr_rebase_develop.yml
@@ -219,7 +237,10 @@ jobs:
219237
needs: [ add_initial_reaction ]
220238

221239
# Define the conditions under which the job should run:
222-
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/stdlib help')
240+
if: |
241+
github.event.issue.pull_request &&
242+
startsWith(github.event.comment.body, '/stdlib help') &&
243+
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)
223244
224245
# Define the job's steps:
225246
steps:

0 commit comments

Comments
 (0)