Skip to content

Telegram Assistant

Telegram Assistant #7

name: Telegram Assistant
on:
schedule:
- cron: "0 */6 * * *"
workflow_dispatch: {}
concurrency:
group: telegram-qa
cancel-in-progress: true
permissions:
contents: read
actions: write # needed to delete old cache entries in the cleanup step below
jobs:
run:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements.txt
- name: Restore recent news context
uses: actions/cache/restore@v4
with:
path: data/recent_news.json
key: recent-news-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
recent-news-${{ runner.os }}-
- name: Run Telegram Assistant
env:
TELEGRAM_BOT_TOKEN_01: ${{ secrets.TELEGRAM_BOT_TOKEN_01 }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
GEMINI_MODEL: ${{ vars.GEMINI_MODEL }}
run: python src/telegram_assistant.py
- name: Delete previous cache entries
if: always()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh extension install actions/gh-actions-cache --pin v1.0.2 || true
set +e
for key in $(gh actions-cache list -R "${{ github.repository }}" --prefix "recent-news-" | cut -f 1); do
gh actions-cache delete "$key" -R "${{ github.repository }}" --confirm
done
exit 0
- name: Save recent news context
if: always()
uses: actions/cache/save@v4
with:
path: data/recent_news.json
key: recent-news-${{ runner.os }}-${{ github.run_id }}