Skip to content

Commit 036ce67

Browse files
committed
chore: restrict slash commands to users with write access
Restrict the `check-files`, `update-copyright-years`, `lint-autofix`, `merge`, and `rebase` slash commands so they only run when triggered by a user whose comment author association is `OWNER`, `MEMBER`, or `COLLABORATOR`. --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent cf7b40a commit 036ce67

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

.github/workflows/slash_commands.yml

Lines changed: 20 additions & 5 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
@@ -132,7 +135,10 @@ jobs:
132135
name: 'Update copyright header years'
133136

134137
# 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')
138+
if: |
139+
github.event.issue.pull_request &&
140+
startsWith(github.event.comment.body, '/stdlib update-copyright-years') &&
141+
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)
136142
137143
# Run reusable workflow:
138144
uses: ./.github/workflows/update_pr_copyright_years.yml
@@ -153,7 +159,10 @@ jobs:
153159
needs: [ add_initial_reaction ]
154160

155161
# Define the conditions under which the job should run:
156-
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/stdlib lint-autofix')
162+
if: |
163+
github.event.issue.pull_request &&
164+
startsWith(github.event.comment.body, '/stdlib lint-autofix') &&
165+
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)
157166
158167
# Run reusable workflow:
159168
uses: ./.github/workflows/lint_autofix.yml
@@ -174,7 +183,10 @@ jobs:
174183
needs: [ add_initial_reaction ]
175184

176185
# Define the conditions under which the job should run:
177-
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/stdlib merge')
186+
if: |
187+
github.event.issue.pull_request &&
188+
startsWith(github.event.comment.body, '/stdlib merge') &&
189+
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)
178190
179191
# Run reusable workflow:
180192
uses: ./.github/workflows/pr_merge_develop.yml
@@ -195,7 +207,10 @@ jobs:
195207
needs: [ add_initial_reaction ]
196208

197209
# Define the conditions under which the job should run:
198-
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/stdlib rebase')
210+
if: |
211+
github.event.issue.pull_request &&
212+
startsWith(github.event.comment.body, '/stdlib rebase') &&
213+
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)
199214
200215
# Run reusable workflow:
201216
uses: ./.github/workflows/pr_rebase_develop.yml

0 commit comments

Comments
 (0)