Skip to content

Commit 3e2aef8

Browse files
committed
fix: add retries for removals too
1 parent f04753c commit 3e2aef8

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

action.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,27 @@ runs:
146146
git commit --message="ci: remove preview for ${{ steps.parse_action.outputs.path }}
147147
148148
Commit created with [EndBug/pages-preview](https://github.com/EndBug/pages-preview)" --allow-empty
149-
git push origin ${{ inputs.preview_branch }}
149+
150+
# Retry loop for safe push
151+
max_attempts=5
152+
attempt=1
153+
154+
while [ $attempt -le $max_attempts ]; do
155+
echo "🔄 Attempt $attempt to push changes..."
156+
git pull --rebase origin ${{ inputs.preview_branch }} || exit 1
157+
if git push origin ${{ inputs.preview_branch }}; then
158+
echo "✅ Push successful"
159+
break
160+
fi
161+
attempt=$(( attempt + 1 ))
162+
echo "⚠️ Push failed due to concurrent changes, retrying in 3s..."
163+
sleep 3
164+
done
165+
166+
if [ $attempt -gt $max_attempts ]; then
167+
echo "❌ Failed to push after $max_attempts attempts"
168+
exit 1
169+
fi
150170
151171
- name: Check whether there has been any change in the preview repo
152172
if: ${{ steps.parse_action.outputs.action != 'none' }}

0 commit comments

Comments
 (0)