Skip to content

Conversation

@transphorm
Copy link
Member

@transphorm transphorm commented Oct 10, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Prevents duplicate version-bump pull requests by checking for an existing open PR before creating a new one.
  • Chores

    • Uses timestamped branch names to reduce collisions during concurrent runs.
    • Improves workflow logging by printing the existing PR number and URL when detected.
    • Retains version bump logic while guarding PR creation with the new check.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 10, 2025

Walkthrough

Updates the mobile deploy GitHub Actions workflow to detect existing open bump PRs before creating a new one, switch to timestamped branch names, and exit early if a matching PR exists. Version bump logic remains, but PR creation is now guarded by the new check.

Changes

Cohort / File(s) Summary of changes
Workflow PR guard and branch naming
\.github/workflows/mobile-deploy.yml
Added search for existing open PRs targeting the bump branch and early exit with PR details; changed branch naming to include a timestamp; retained version bump steps but gated PR creation on the new check.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor Dev as GitHub Actions Runner
    participant GH as GitHub API
    participant Repo as Repo
    participant PR as Pull Requests

    Dev->>GH: Query open PRs targeting bump branch (matching criteria)
    alt Existing PR found
        GH-->>Dev: Return PR number and URL
        Note right of Dev: Log existing PR info and exit
    else No existing PR
        Dev->>Repo: Create branch with timestamped name
        Dev->>Repo: Apply version bump commits
        Dev->>Repo: Push branch
        Dev->>GH: Create new PR to target branch
        GH-->>Dev: PR created (number, URL)
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

skip-deploy

Suggested reviewers

  • remicolin

Poem

A branch with time stitched in its name,
Checks the halls for PRs the same.
If one exists, we tip our hat—
No duplicate, no merging spat.
Quietly we pass the torch,
One clean bump upon the porch.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly and concisely summarizes the main update—adding a timestamp to the automated mobile pull‐request branch name—which accurately reflects the primary change in the workflow file.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch justin/chore-randomize-mobile-auto-pr-branch-name

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/mobile-deploy.yml (1)

1331-1339: Existing-PR detection is brittle (title-only match, default limit 30, race-prone)

Title substring matching can false-positive; pagination can miss matches; race still possible. Filter by label/author and raise the limit. Example improvement:

-EXISTING_PR=$(gh pr list --base "${TARGET_BRANCH}" --state open --json number,title,headRefName --jq ".[] | select(.title | contains(\"${VERSION}\")) | .number" | head -1)
+EXISTING_PR=$(
+  gh pr list \
+    --base "${TARGET_BRANCH}" \
+    --state open \
+    --limit 200 \
+    --search "in:title ${VERSION} label:automated author:app/github-actions" \
+    --json number \
+    --jq '.[0].number' \
+  | head -1
+)

Optional: repeat the same check immediately before gh pr create to reduce race windows.

If the "automated" label might not exist, either create it beforehand or drop the label filter and match headRefName prefix:

-    --search "in:title ${VERSION} label:automated author:app/github-actions" \
+    --search "in:title ${VERSION} author:app/github-actions" \
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5bb7cef and 64c5e93.

📒 Files selected for processing (1)
  • .github/workflows/mobile-deploy.yml (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
.github/workflows/**/*.{yml,yaml}

📄 CodeRabbit inference engine (AGENTS.md)

.github/workflows/**/*.{yml,yaml}: In GitHub workflows, use the shared composite actions in .github/actions for dependency caching instead of calling actions/cache directly
Use the cache-yarn composite action for Yarn dependency caching in workflows
Use the cache-bundler composite action for Ruby gems caching in workflows
Use the cache-gradle composite action for Gradle caching in workflows
Use the cache-pods composite action for CocoaPods caching in workflows

Files:

  • .github/workflows/mobile-deploy.yml

Comment on lines +1323 to 1326
# Add timestamp to branch name to avoid collisions
TIMESTAMP=$(date +%s%N | cut -b1-13) # Milliseconds since epoch (13 digits)
BRANCH_NAME="ci/bump-mobile-version-${VERSION}-${TIMESTAMP}"
PR_TITLE="${{ steps.platforms.outputs.pr_title }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Timestamped branch avoids collisions, but duplicate PRs can slip in during races

Two concurrent runs can both pass the pre-check and open two PRs for the same version (different timestamps). Add a second existence check right before gh pr create (after push), or strengthen global concurrency to serialize by bump_target_branch to prevent duplicates.

Suggested follow-ups:

  • Re-check for existing PR after the push, before creation.
  • Consider tying the workflow concurrency group to bump_target_branch to serialize PR creation to the same target branch.
🤖 Prompt for AI Agents
.github/workflows/mobile-deploy.yml around lines 1323 to 1326: the workflow
creates a timestamped branch to avoid collisions but may still open duplicate
PRs from concurrent runs; add a second check for an existing PR after the git
push and before running gh pr create, and/or scope the workflow concurrency to
the bump_target_branch so runs targeting the same branch are serialized;
implement by querying GitHub (gh pr list or API) for an open PR that matches the
intended version/target branch immediately after push and abort creation if
found, or set the workflow concurrency group to include bump_target_branch to
prevent parallel PR creation.

@transphorm transphorm merged commit 702a683 into dev Oct 10, 2025
13 checks passed
@transphorm transphorm deleted the justin/chore-randomize-mobile-auto-pr-branch-name branch October 10, 2025 21:23
transphorm added a commit that referenced this pull request Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants