|
| 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 }} }}' |
0 commit comments