|
12 | 12 | branches: |
13 | 13 | - 'plot/**' # PRs targeting feature branches |
14 | 14 |
|
| 15 | + # Manual trigger for reviewing specific PRs |
| 16 | + workflow_dispatch: |
| 17 | + inputs: |
| 18 | + pr_number: |
| 19 | + description: 'PR number to review' |
| 20 | + required: true |
| 21 | + type: string |
| 22 | + |
15 | 23 | jobs: |
16 | 24 | ai-review: |
17 | | - # Only run for auto/* branches (generated implementations) |
18 | | - if: startsWith(github.event.pull_request.head.ref, 'auto/') |
| 25 | + # Run for auto/* branches OR manual workflow_dispatch |
| 26 | + if: > |
| 27 | + github.event_name == 'workflow_dispatch' || |
| 28 | + startsWith(github.event.pull_request.head.ref, 'auto/') |
19 | 29 | runs-on: ubuntu-latest |
20 | 30 | permissions: |
21 | 31 | contents: read |
|
28 | 38 | - name: Extract PR info |
29 | 39 | id: get_pr |
30 | 40 | env: |
| 41 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + # For pull_request_target |
31 | 43 | HEAD_REF: ${{ github.event.pull_request.head.ref }} |
32 | | - PR_NUMBER: ${{ github.event.pull_request.number }} |
| 44 | + PR_NUMBER_EVENT: ${{ github.event.pull_request.number }} |
| 45 | + # For workflow_dispatch |
| 46 | + PR_NUMBER_INPUT: ${{ inputs.pr_number }} |
33 | 47 | run: | |
| 48 | + # Determine PR number based on trigger type |
| 49 | + if [ -n "$PR_NUMBER_INPUT" ]; then |
| 50 | + # workflow_dispatch - lookup PR info |
| 51 | + PR_NUMBER="$PR_NUMBER_INPUT" |
| 52 | + PR_DATA=$(gh pr view "$PR_NUMBER" --json headRefName,headRefOid) |
| 53 | + HEAD_REF=$(echo "$PR_DATA" | jq -r '.headRefName') |
| 54 | + HEAD_SHA=$(echo "$PR_DATA" | jq -r '.headRefOid') |
| 55 | + echo "head_sha=$HEAD_SHA" >> $GITHUB_OUTPUT |
| 56 | + else |
| 57 | + # pull_request_target |
| 58 | + PR_NUMBER="$PR_NUMBER_EVENT" |
| 59 | + echo "head_sha=${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT |
| 60 | + fi |
| 61 | +
|
34 | 62 | # Extract spec-id and library from branch name (auto/{spec-id}/{library}) |
35 | 63 | SPEC_ID=$(echo "$HEAD_REF" | cut -d'/' -f2) |
36 | 64 | LIBRARY=$(echo "$HEAD_REF" | cut -d'/' -f3) |
|
45 | 73 | uses: actions/checkout@v6 |
46 | 74 | with: |
47 | 75 | # Checkout PR head to review the actual implementation |
48 | | - ref: ${{ github.event.pull_request.head.sha }} |
| 76 | + ref: ${{ steps.get_pr.outputs.head_sha }} |
49 | 77 | fetch-depth: 0 |
50 | 78 |
|
51 | 79 | - name: Get main issue number from PR |
|
0 commit comments