Skip to content

Commit 77aef8d

Browse files
authored
Implement concurrency and simplify git push logic
Added concurrency control to ensure only one run at a time and removed retry logic for git push commands.
1 parent 7bc0e97 commit 77aef8d

1 file changed

Lines changed: 9 additions & 46 deletions

File tree

.github/workflows/update_dsa.yml

Lines changed: 9 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ on:
1111
permissions:
1212
contents: write
1313

14+
# ✅ KEY FIX: Only one run at a time — new runs wait, not cancel
15+
concurrency:
16+
group: update-dsa-progress
17+
cancel-in-progress: false
18+
1419
jobs:
1520
update-readmes:
1621
runs-on: ubuntu-latest
@@ -38,40 +43,19 @@ jobs:
3843
- name: Update java_progress README
3944
run: python .github/update_readme.py
4045

41-
# ── 4. Commit + push java_progress README (with retry)
46+
# ── 4. Commit + push java_progress README ─────────────
4247
- name: Commit java_progress README
4348
run: |
4449
git config user.name "github-actions[bot]"
4550
git config user.email "github-actions[bot]@users.noreply.github.com"
4651
git pull --rebase origin main
4752
git add README.md
48-
4953
if git diff --staged --quiet; then
5054
echo "No changes to commit, skipping."
5155
exit 0
5256
fi
53-
5457
git commit -m "📊 Auto-update DSA progress table"
55-
56-
set +e # ← disable exit-on-error so the loop can retry
57-
PUSHED=false
58-
for i in 1 2 3 4 5; do
59-
echo "Push attempt $i of 5..."
60-
git pull --rebase origin main
61-
if git push; then
62-
echo "✅ Push succeeded on attempt $i!"
63-
PUSHED=true
64-
break
65-
fi
66-
echo "❌ Push failed, waiting 5s before retry..."
67-
sleep 5
68-
done
69-
set -e # ← re-enable exit-on-error
70-
71-
if [ "$PUSHED" = false ]; then
72-
echo "💀 All push attempts failed."
73-
exit 1
74-
fi
58+
git push
7559
7660
# ── 5. Checkout profile repo (rajit2004/rajit2004) ─────
7761
- name: Checkout profile repo
@@ -105,38 +89,17 @@ jobs:
10589
print("[+] Profile README updated.")
10690
EOF
10791
108-
# ── 7. Commit + push profile README (with retry) ───────
92+
# ── 7. Commit + push profile README ───────────────────
10993
- name: Commit profile README
11094
working-directory: profile-repo
11195
run: |
11296
git config user.name "github-actions[bot]"
11397
git config user.email "github-actions[bot]@users.noreply.github.com"
11498
git pull --rebase origin main
11599
git add README.md
116-
117100
if git diff --staged --quiet; then
118101
echo "No changes to commit, skipping."
119102
exit 0
120103
fi
121-
122104
git commit -m "📊 Auto-update DSA progress table from java_progress"
123-
124-
set +e
125-
PUSHED=false
126-
for i in 1 2 3 4 5; do
127-
echo "Push attempt $i of 5..."
128-
git pull --rebase origin main
129-
if git push; then
130-
echo "✅ Push succeeded on attempt $i!"
131-
PUSHED=true
132-
break
133-
fi
134-
echo "❌ Push failed, waiting 5s before retry..."
135-
sleep 5
136-
done
137-
set -e
138-
139-
if [ "$PUSHED" = false ]; then
140-
echo "💀 All push attempts failed."
141-
exit 1
142-
fi
105+
git push

0 commit comments

Comments
 (0)