Triggering AI review commands on PR #34
This file contains hidden or 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: AI Command Handler | |
| run-name: Triggering AI review commands on PR #${{ github.event.client_payload.slash_command.args.named.prId }} | |
| concurrency: | |
| group: ai-command-${{ github.event.client_payload.slash_command.args.named.prId || github.event.inputs.prId }} | |
| cancel-in-progress: true | |
| on: | |
| repository_dispatch: | |
| types: [ai-command] | |
| # this should only be used for testing purposes. | |
| workflow_dispatch: | |
| inputs: | |
| prId: | |
| description: "PR to deploy" | |
| required: true | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| getPRHead: | |
| name: Get PR head SHA | |
| runs-on: ubuntu-latest | |
| outputs: | |
| sha: ${{ steps.pr-head.outputs.result }} | |
| steps: | |
| - name: Get PR head SHA | |
| id: pr-head | |
| uses: actions/github-script@v7 | |
| with: | |
| result-encoding: string | |
| script: | | |
| const prId = ${{ | |
| (github.event_name == 'repository_dispatch' && github.event.client_payload.slash_command.args.named.prId) | |
| || github.event.inputs.prId | |
| }}; | |
| const { data: pr } = await github.rest.pulls.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: parseInt(prId, 10) | |
| }); | |
| return pr.head.sha; | |
| triggerAiReview: | |
| name: Trigger AI Review Commands | |
| runs-on: ubuntu-latest | |
| needs: getPRHead | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.getPRHead.outputs.sha }} | |
| - name: Setup CI | |
| uses: ./.github/composite/setup-ci | |
| with: | |
| GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | |
| GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
| - name: Load secrets | |
| uses: ./.github/composite/load-secrets | |
| with: | |
| GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | |
| GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
| UNLOAD_ENVIRONMENTS: ci | |
| - name: Post /review command | |
| uses: ./.github/composite/send-message | |
| with: | |
| prId: ${{ | |
| (github.event_name == 'repository_dispatch' && github.event.client_payload.slash_command.args.named.prId) | |
| || github.event.inputs.prId | |
| }} | |
| message: "/review" | |
| token: ${{ env.GH_PAT }} | |
| - name: Post /describe command | |
| uses: ./.github/composite/send-message | |
| with: | |
| prId: ${{ | |
| (github.event_name == 'repository_dispatch' && github.event.client_payload.slash_command.args.named.prId) | |
| || github.event.inputs.prId | |
| }} | |
| message: "/describe" | |
| token: ${{ env.GH_PAT }} | |
| - name: Post /improve command | |
| uses: ./.github/composite/send-message | |
| with: | |
| prId: ${{ | |
| (github.event_name == 'repository_dispatch' && github.event.client_payload.slash_command.args.named.prId) | |
| || github.event.inputs.prId | |
| }} | |
| message: "/improve" | |
| token: ${{ env.GH_PAT }} |