Skip to content

Commit 77822c2

Browse files
authored
Merge pull request #279 from mfalt/comment-test
Script to respond to comments in PRs
2 parents fe4e627 + 25c34c0 commit 77822c2

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: PR Comment Responder
2+
on:
3+
issue_comment:
4+
types: [created] # Trigger when comment is created on issue or PR
5+
6+
jobs:
7+
mentioned:
8+
runs-on: ubuntu-latest
9+
if: contains(github.event.comment.body, '@JuliaControlBot test-plots') # Only run if requested
10+
steps:
11+
- id: get_user_permissons # Get permissions for user who commented
12+
uses: octokit/request-action@v2.x
13+
with:
14+
route: GET /repos/JuliaControl/ControlSystems.jl/collaborators/:user/permission
15+
user: ${{ github.event.comment.user.login }}
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This is a short-time token generated by github
18+
19+
- id: parse_permisson # Parse permissions for user who commented, save in "outputs.permission"
20+
uses: gr2m/get-json-paths-action@v1.x
21+
with:
22+
json: ${{ steps.get_user_permissons.outputs.data }}
23+
permission: "permission"
24+
25+
26+
- name: Is admin # For debugging, check if admin
27+
if: steps.parse_permisson.outputs.permission == 'admin'
28+
run: |
29+
echo Is admin
30+
- name: Is PR # For debugging, check if comment is in PR
31+
if: github.event.issue.pull_request != null
32+
run: |
33+
echo Is PR
34+
- name: PR ping ControlExamplePlots # Post the ping to ControlExamplePlots to handle, using secret key for JuliaControlBot
35+
if: github.event.issue.pull_request != null && steps.parse_permisson.outputs.permission == 'admin'
36+
run: |
37+
curl -X POST https://api.github.com/repos/JuliaControl/ControlExamplePlots.jl/dispatches \
38+
-H 'Accept: application/vnd.github.everest-preview+json' \
39+
-u ${{ secrets.ACCESS_TOKEN_BOT }} \
40+
--data '{"event_type": "prupdate", "client_payload": { "repository": "'"$GITHUB_REPOSITORY"'", "pr_number": ${{ github.event.issue.number }} }}'

.github/workflows/PingControlExamplePlots.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ jobs:
1010
steps:
1111
- name: PR ping ControlExamplePlots
1212
run: |
13+
if [ "$SECRET" != "" ]; then
1314
curl -X POST https://api.github.com/repos/JuliaControl/ControlExamplePlots.jl/dispatches \
1415
-H 'Accept: application/vnd.github.everest-preview+json' \
1516
-u ${{ secrets.ACCESS_TOKEN_BOT }} \
1617
--data '{"event_type": "prupdate", "client_payload": { "repository": "'"$GITHUB_REPOSITORY"'", "pr_number": ${{ github.event.number }} }}'
18+
fi
19+
env:
20+
SECRET: ${{ secrets.ACCESS_TOKEN_BOT }}

0 commit comments

Comments
 (0)