Skip to content

matrix-command

matrix-command #268

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 }}