Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions .github/workflows/mobile-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1320,18 +1320,21 @@ jobs:
run: |
VERSION="${{ needs.bump-version.outputs.version }}"
TARGET_BRANCH="${{ inputs.bump_target_branch || 'dev' }}"
# Use version-based branch name for idempotency
BRANCH_NAME="ci/bump-mobile-version-${VERSION}"
# 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 }}"
Comment on lines +1323 to 1326
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.


git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

# Check if branch already exists (idempotent PR creation)
if git ls-remote --heads origin "${BRANCH_NAME}" | grep -q "${BRANCH_NAME}"; then
echo "⚠️ Branch ${BRANCH_NAME} already exists"
echo "ℹ️ Version bump PR may already exist for version ${VERSION}"
# Check if a PR already exists for this version (avoid duplicate PRs)
EXISTING_PR=$(gh pr list --base "${TARGET_BRANCH}" --state open --json number,title,headRefName --jq ".[] | select(.title | contains(\"${VERSION}\")) | .number" | head -1)

if [ -n "$EXISTING_PR" ]; then
echo "⚠️ PR #${EXISTING_PR} already exists for version ${VERSION}"
echo "ℹ️ Skipping PR creation to avoid duplicates"
echo "ℹ️ Existing PR: https://github.com/${{ github.repository }}/pull/${EXISTING_PR}"
exit 0
fi

Expand Down
Loading