fetcher-telegram #3068
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |