File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -283,15 +283,11 @@ jobs:
283283 git worktree remove --force ../deploy-worktree || true
284284 fi
285285
286- # Fetch remote branch into local if needed
287- if ! git show-ref --verify --quiet refs/remotes/origin/$BRANCH; then
288- git fetch origin $BRANCH:$BRANCH || git checkout --orphan $BRANCH
289- else
290- git fetch origin $BRANCH
291- fi
286+ # Fetch latest remote branch
287+ git fetch origin $BRANCH || git checkout --orphan $BRANCH
292288
293289 # Add isolated worktree for that branch
294- git worktree add ../deploy-worktree $BRANCH
290+ git worktree add ../deploy-worktree FETCH_HEAD
295291
296292 # Ensure destination directory exists
297293 mkdir -p "$(dirname ../deploy-worktree/$FILE)"
@@ -302,9 +298,13 @@ jobs:
302298 # Commit and push if there are changes
303299 cd ../deploy-worktree
304300 git add "$FILE"
305- git commit -m "chore(ci): promote to $ENV [skip ci]" || echo "⚠️ Nothing to commit"
306- git push origin $BRANCH
307-
301+ if git commit -m "chore(ci): promote to $ENV [skip ci]"; then
302+ # Rebase to preserve remote history
303+ git pull --rebase origin $BRANCH
304+ git push origin HEAD:$BRANCH
305+ else
306+ echo "⚠️ Nothing to commit"
307+ fi
308308
309309 - name : Check if there are commits between staging to main
310310 id : check_commits
You can’t perform that action at this time.
0 commit comments