add timestamp to branch name (#1261)

This commit is contained in:
Justin Hernandez
2025-10-10 14:23:30 -07:00
committed by GitHub
parent 5bb7cef34b
commit 702a6836c7

View File

@@ -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 }}"
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