-
Notifications
You must be signed in to change notification settings - Fork 220
49 lines (44 loc) · 1.36 KB
/
matrix-command.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
name: matrix-command
on:
pull_request_review:
types:
- submitted
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
permissions:
contents: read
jobs:
command-validation:
if: startsWith(github.event.review.body, '/test matrix')
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
pull-requests: write
steps:
- name: Is comment allowed?
uses: actions/github-script@v7
with:
script: |
const actorPermission = (await github.rest.repos.getCollaboratorPermissionLevel({
...context.repo,
username: context.actor
})).data.permission
const isPermitted = ['write', 'admin'].includes(actorPermission)
if (!isPermitted) {
const errorMessage = 'Only users with write permission to the repository can run GitHub commands'
await github.rest.issues.createComment({
...context.repo,
issue_number: context.issue.number,
body: errorMessage,
})
core.setFailed(errorMessage)
return
}
test:
needs:
- command-validation
uses: ./.github/workflows/test.yml
with:
full-matrix: true
ref: ${{ github.event.pull_request.head.sha }}