Fetch Telegram Channel Posts #7
This file contains 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: Fetch Telegram Channel Posts | |
on: | |
workflow_dispatch: # Allow manual triggering | |
schedule: | |
- cron: '0 */6 * * *' # Run every 6 hours | |
jobs: | |
fetch-posts: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.9' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install python-telegram-bot requests | |
- name: Fetch Telegram Channel Posts | |
env: | |
BOT_TOKEN: ${{ secrets.BOT_TOKEN }} | |
CHANNEL_ID: ${{ secrets.CHANNEL_ID }} | |
CHANNEL_USERNAME: ${{ secrets.CHANNEL_USERNAME }} | |
run: python bot/main.py | |
- name: Commit and push changes | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add public/data/posts.json public/media/* | |
git commit -m "Update Telegram channel posts" || echo "No changes to commit" | |
git push |