-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (53 loc) · 1.74 KB
/
Copy pathupdate-recent.yml
File metadata and controls
62 lines (53 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
name: Update Recent Solutions
on:
push:
branches: [ main ]
schedule:
- cron: "0 0 * * *" # 매일 00:00 UTC (KST 09:00)
workflow_dispatch:
concurrency:
group: update-recent-${{ github.ref }}
cancel-in-progress: false
jobs:
update:
runs-on: ubuntu-latest
permissions:
contents: write
env:
LIMIT: "20" # 최근 항목 개수 (원하면 15, 20 등으로 변경)
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # 전체 히스토리 필요
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Run updater
run: |
python3 scripts/update-recent.py
- name: Commit & Push if changed
run: |
if git diff --quiet README.md; then
echo "No README changes."
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add README.md
git commit -m "chore(readme): auto-update recent solutions"
# 원격이 앞서있을 수 있으니 rebase 후 재시도 (최대 5회, jittered backoff)
for i in 1 2 3 4 5; do
if git push; then
echo "Pushed on attempt $i."
exit 0
fi
echo "Push rejected (attempt $i). Rebasing on latest origin/main and retrying..."
if ! git pull --rebase --autostash origin main; then
echo "Rebase failed on attempt $i; aborting rebase." >&2
git rebase --abort || true
exit 1
fi
sleep $((RANDOM % 5 + i))
done
echo "Failed to push after 5 attempts." >&2
exit 1