Skip to content

Commit d164cab

Browse files
committed
Harden forecast workflow pushes with retry/rebase loop for concurrent runs
1 parent 0ede4a8 commit d164cab

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

.github/workflows/forecast-request.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,28 @@ jobs:
5959
--m5-series-count "${{ inputs.m5_series_count }}" \
6060
--backtest-windows "${{ inputs.backtest_windows }}"
6161
62-
- name: Commit output
62+
- name: Commit output (retry-safe for concurrent runs)
6363
run: |
6464
git config user.name "github-actions[bot]"
6565
git config user.email "github-actions[bot]@users.noreply.github.com"
6666
git add site/src/data/forecasts
6767
git commit -m "Add forecast ${{ inputs.slug }}" || echo "No changes"
68-
git pull --rebase origin main
69-
git push
68+
69+
# Concurrent workflow runs can race on push. Retry with rebase.
70+
for i in 1 2 3 4 5; do
71+
echo "Push attempt $i..."
72+
git fetch origin main
73+
git rebase origin/main || { git rebase --abort; }
74+
if git push origin HEAD:main; then
75+
echo "Push succeeded on attempt $i"
76+
break
77+
fi
78+
if [ "$i" -eq 5 ]; then
79+
echo "Push failed after 5 attempts"
80+
exit 1
81+
fi
82+
sleep $((RANDOM % 5 + 2))
83+
done
7084
7185
- name: Setup Node for site build
7286
uses: actions/setup-node@v4

0 commit comments

Comments
 (0)