matrix-command #268
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |