ci(upstream): use explicit remote lease to update existing review branch safely
davoodmehraban89 committed
Oct 14, 2026 at 23:32 UTC
7feee38ccae9585163f68741ee93f83d18b5d5c8
1 file changed
+9
-1
.github/workflows/medusa-upstream-review.yml
+9
-1
@@ -61,7 +61,15 @@ jobs:
61
echo "HAS_CHANGES=false" >> "$GITHUB_ENV"
62
else
63
git commit -m "Review Medusa upstream develop at $UPSTREAM_SHA"
64
- git push --force-with-lease origin HEAD:refs/heads/automation/medusa-upstream-review
64
+ # Checkout of main does not fetch the automation branch. Obtain
65
+ # the exact remote SHA and use an explicit optimistic-concurrency
66
+ # lease; an unrelated concurrent update must NOT be overwritten.
67
+ REMOTE_SHA=$(git ls-remote --heads origin refs/heads/automation/medusa-upstream-review | awk '{print $1}')
68
+ if [[ -n "$REMOTE_SHA" ]]; then
69
+ git push --force-with-lease=refs/heads/automation/medusa-upstream-review:"$REMOTE_SHA" origin HEAD:refs/heads/automation/medusa-upstream-review
70
+ else
71
+ git push origin HEAD:refs/heads/automation/medusa-upstream-review
72
+ fi
73
echo "HAS_CHANGES=true" >> "$GITHUB_ENV"
74
fi
75