-
Notifications
You must be signed in to change notification settings - Fork 1.2k
68 lines (55 loc) · 1.85 KB
/
Copy pathfetcher-telegram.yml
File metadata and controls
68 lines (55 loc) · 1.85 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
63
64
65
66
67
68
name: fetcher-telegram
on:
# schedule:
# - cron: "*/30 * * * *"
workflow_dispatch:
permissions:
contents: write
jobs:
fetch:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install Python dependencies
run: pip install playwright requests jdatetime
- name: Install Chromium for Playwright
run: |
python -m playwright install chromium
python -m playwright install-deps chromium
- name: Run archiver
run: python .github/script/fetch_telegram_pw.py
- name: Commit and push changes
env:
BRANCH: ${{ github.ref_name }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git config http.postBuffer 524288000
# Stage only if files exist (avoid error on empty content dir)
if [ -d telegram/content ]; then git add telegram/content/; fi
git add telegram/last_ids.json telegram.md
# Skip commit if nothing changed
if git diff --staged --quiet; then
echo "No changes to commit."
exit 0
fi
# Commit with a descriptive message
git commit -m "Update Telegram messages [skip ci]"
# Retry loop with pull‑rebase to avoid conflicts
RETRIES=5
for i in $(seq 1 $RETRIES); do
echo "Push attempt $i..."
git pull --rebase --autostash origin "$BRANCH"
if git push origin "$BRANCH"; then
echo "Push succeeded."
break
else
echo "Push failed."
[ $i -lt $RETRIES ] && sleep 3 || exit 1
fi
done