Sync Tzevaadomm Messages #4
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: Sync Tzevaadomm Messages | |
on: | |
schedule: | |
- cron: '0 2 * * *' # Runs daily at 2 AM UTC | |
workflow_dispatch: | |
jobs: | |
sync-telegram: | |
runs-on: ubuntu-latest | |
environment: Telegram | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install OpenSSL | |
run: | | |
sudo apt-get update -q | |
sudo apt-get install -y openssl | |
openssl version | |
- name: Decode and decrypt Telegram session file | |
run: | | |
echo "${{ secrets.TELEGRAM_SESSION_ENC }}" | base64 --decode > session_telegram_scraper.session.enc | |
openssl enc -aes-256-cbc -pbkdf2 -iter 100000 -d -in session_telegram_scraper.session.enc -out code/telegram/session_telegram_scraper.session -k "${{ secrets.ENCRYPTION_PASSWORD }}" | |
echo "Decryption successful!" | |
- name: Debug session file | |
run: | | |
ls -l 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@v3 | |
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 }} |