-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PR review comment command (#1960)
* Add PR review comment command * Add to README.md * Update .github/workflows/README.md Co-authored-by: Victor Martinez <victormartinezrubio@gmail.com> * Update .github/workflows/test.yml --------- Co-authored-by: Victor Martinez <victormartinezrubio@gmail.com>
- Loading branch information
Showing
3 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 }} |
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