Skip to content

Sync Tzevaadomm Messages #27

Sync Tzevaadomm Messages

Sync Tzevaadomm Messages #27

name: Sync Tzevaadomm Messages
on:
schedule:
- cron: '0 2 * * *' # Runs daily at 2 AM UTC
workflow_dispatch:
jobs:
sync-telegram:
runs-on:
group: ims-cloud
labels: [self-hosted, Linux, X64, Python]
environment: Telegram
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Verify session file exists locally
run: |
# Ensure the session file exists in the specified path
if [ ! -f "/home/ims/session-file/session_telegram_scraper.session" ]; then
echo "Session file not found at /home/ims/session-file!"
exit 1
fi
echo "Session file found at /home/ims/session-file!"
shell: bash
- name: Copy session file to working directory
run: |
# Copy the local session file to the workflow directory
cp /home/ims/session-file/session_telegram_scraper.session $GITHUB_WORKSPACE/code/telegram/session_telegram_scraper.session
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Cache Python dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('code/telegram/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: pip install --no-cache-dir -r code/telegram/requirements.txt
- name: Run Tzevaadomm Telegram scraping script
env:
TELEGRAM_API_ID: ${{ secrets.TELEGRAM_API_ID }}
TELEGRAM_API_HASH: ${{ secrets.TELEGRAM_API_HASH }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python code/telegram/export_tzevaadomm_telegram.py
- name: Commit and push changes
run: |
git config --global user.name "${{ secrets.GIT_USER_NAME }}"
git config --global user.email "${{ secrets.GIT_USER_EMAIL }}"
git add .
git commit -m "Sync Telegram messages [$(date -u)]" || echo "No changes to commit"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}