Skip to content

Commit e969597

Browse files
committed
ci: harden workflow pushes to main
1 parent bf0a09c commit e969597

File tree

3 files changed

+66
-7
lines changed

3 files changed

+66
-7
lines changed

.github/workflows/build-docs.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
jobs:
88
build-docs:
99
runs-on: ubuntu-latest
10+
concurrency:
11+
group: flowquery-main-writers-${{ github.ref_name }}
12+
cancel-in-progress: false
1013
permissions:
1114
contents: write
1215
steps:
@@ -40,5 +43,26 @@ jobs:
4043
git config user.name "github-actions[bot]"
4144
git config user.email "github-actions[bot]@users.noreply.github.com"
4245
git add docs/
43-
git diff --staged --quiet || git commit -m "chore: rebuild docs [skip ci]"
44-
git push
46+
47+
if git diff --staged --quiet; then
48+
exit 0
49+
fi
50+
51+
git commit -m "chore: rebuild docs [skip ci]"
52+
53+
for attempt in 1 2 3; do
54+
git fetch origin main:refs/remotes/origin/main
55+
56+
if ! git rebase origin/main; then
57+
git rebase --abort || true
58+
elif git push origin HEAD:main; then
59+
break
60+
fi
61+
62+
if [ "$attempt" -eq 3 ]; then
63+
echo "Failed to push docs rebuild after 3 attempts."
64+
exit 1
65+
fi
66+
67+
sleep 5
68+
done

.github/workflows/python-publish.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ jobs:
2727
name: Bump version
2828
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/')
2929
runs-on: ubuntu-latest
30+
concurrency:
31+
group: flowquery-main-writers-${{ github.ref_name }}
32+
cancel-in-progress: false
3033
outputs:
3134
new_version: ${{ steps.bump.outputs.new_version }}
3235

@@ -57,7 +60,23 @@ jobs:
5760
git config user.email "github-actions[bot]@users.noreply.github.com"
5861
git add pyproject.toml
5962
git commit -m "chore(py): bump version to $NEW_VERSION [skip ci]"
60-
git push
63+
64+
for attempt in 1 2 3; do
65+
git fetch origin main:refs/remotes/origin/main
66+
67+
if ! git rebase origin/main; then
68+
git rebase --abort || true
69+
elif git push origin HEAD:main; then
70+
break
71+
fi
72+
73+
if [ "$attempt" -eq 3 ]; then
74+
echo "Failed to push Python version bump after 3 attempts."
75+
exit 1
76+
fi
77+
78+
sleep 5
79+
done
6180
6281
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
6382

.github/workflows/release.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ permissions:
1414
jobs:
1515
build-and-release:
1616
runs-on: ubuntu-latest
17+
concurrency:
18+
group: flowquery-main-writers-${{ github.ref_name }}
19+
cancel-in-progress: false
1720

1821
steps:
1922
- name: Checkout code
@@ -80,10 +83,23 @@ jobs:
8083
git add -A
8184
git diff --cached --quiet || git commit --amend --no-verify --no-edit
8285
83-
# Refresh the tracking ref before rebasing so push uses the current remote tip.
84-
git fetch origin main:refs/remotes/origin/main
85-
git rebase origin/main
86-
git push origin HEAD:main
86+
# Retry the rebase/push sequence in case another workflow updates main first.
87+
for attempt in 1 2 3; do
88+
git fetch origin main:refs/remotes/origin/main
89+
90+
if ! git rebase origin/main; then
91+
git rebase --abort || true
92+
elif git push origin HEAD:main; then
93+
break
94+
fi
95+
96+
if [ "$attempt" -eq 3 ]; then
97+
echo "Failed to push version bump after 3 attempts."
98+
exit 1
99+
fi
100+
101+
sleep 5
102+
done
87103
88104
- name: Install VS Code extension dependencies
89105
working-directory: ./flowquery-vscode

0 commit comments

Comments
 (0)