@@ -513,6 +513,70 @@ workflows:
513
513
'\[Bitrise Analytics\].*🤖 Bitrise analytics enabled for tasks.*Invocation ID: [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
514
514
- deploy-to-bitrise-io@2 : {}
515
515
516
+ ai_pr_summary :
517
+ triggers :
518
+ # run for pull requests; changed_files filter exposes the list of changed files
519
+ pull_request :
520
+ - target_branch : ' *'
521
+ source_branch : ' *'
522
+ changed_files : ' *'
523
+ # Set status_report_name to report the status of this workflow separately.
524
+ status_report_name : ' AI Review'
525
+ # Simple Medium Linux machine is enough
526
+ meta :
527
+ bitrise.io :
528
+ machine_type_id : g2.linux.medium
529
+ stack : linux-docker-android-22.04
530
+ envs :
531
+ - GITHUB_TOKEN : $AI_PR_REVIEWER_GITHUB_TOKEN
532
+ - LLM_API_KEY : $AI_PR_REVIEWER_OPENAI_API_KEY
533
+ steps :
534
+ - activate-ssh-key@4 :
535
+ run_if : ' {{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
536
+
537
+
538
+ title : Generate AI Review for PR
539
+ inputs :
540
+ - content : |-
541
+ #!/bin/bash
542
+ set -e
543
+
544
+ # Parse repository name from repo URL (works for SSH & HTTPS)
545
+ REPO_URL="${GIT_REPOSITORY_URL}"
546
+ REPO=$(echo "$REPO_URL" | sed -E 's#(git@|https://)([^/:]+)[/:]([^/]+)/([^.]+)(\.git)?#\3/\4#')
547
+
548
+ # 1. Unshallow the repo if it's a shallow clone (safe to run even if already full)
549
+ git fetch --unshallow || true
550
+
551
+ # 2. Fetch all branch refs (this ensures both the PR and the target/destination branch are present)
552
+ git fetch origin
553
+
554
+ # 3. Fetch both relevant branches explicitly for safety (redundant but safe)
555
+ git fetch origin "$BITRISEIO_GIT_BRANCH_DEST"
556
+ git fetch origin "$BITRISE_GIT_BRANCH"
557
+
558
+ # 4. Create/reset local branches to match the remote
559
+ git checkout -B "$BITRISEIO_GIT_BRANCH_DEST" "origin/$BITRISEIO_GIT_BRANCH_DEST"
560
+ git checkout -B "$BITRISE_GIT_BRANCH" "origin/$BITRISE_GIT_BRANCH"
561
+
562
+ # (Optionally: check out the PR branch if that is the branch you want to analyze)
563
+ git checkout "$BITRISE_GIT_BRANCH"
564
+
565
+ # 5. Install AI reviewer plugin (customize source as needed)
566
+ bitrise plugin install --source https://github.com/bitrise-io/bitrise-plugins-ai-reviewer.git
567
+
568
+ # 6. Run your AI reviewer (customize flags as needed)
569
+ bitrise :ai-reviewer summarize \
570
+ -m=gpt-4.1 \
571
+ -c="${GIT_CLONE_COMMIT_HASH}" \
572
+ -b="${BITRISEIO_GIT_BRANCH_DEST}" \
573
+ -r=github \
574
+ --pr="${BITRISE_PULL_REQUEST}" \
575
+ --repo="${REPO}" \
576
+ --log-level=debug
577
+
578
+ echo "Done! PR reviewed."
579
+
516
580
step_bundles :
517
581
generate_gradle_verification_reference :
518
582
steps :
0 commit comments