Sync IDF Messages #62
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 IDF Messages | |
on: | |
schedule: | |
- cron: '0 1 * * *' # Runs daily at 1 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: | | |
# Decode Base64-encoded encrypted session file | |
echo "${{ secrets.TELEGRAM_SESSION_ENC }}" | base64 -d > session_telegram_scraper.session.enc | |
# Decrypt the session file | |
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 }}" | |
# Check if decryption was successful | |
if [ ! -f code/telegram/session_telegram_scraper.session ]; then | |
echo "Decryption failed: Session file not found!" | |
exit 1 | |
fi | |
echo "Decryption successful!" | |
- name: Debug session file | |
run: | | |
# Verify the session file exists and display its size | |
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@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 IDF Telegram scraping script | |
env: | |
TELEGRAM_API_ID: ${{ secrets.TELEGRAM_API_ID }} | |
TELEGRAM_API_HASH: ${{ secrets.TELEGRAM_API_HASH }} | |
R2_ACCESS_KEY: ${{ secrets.R2_ACCESS_KEY }} | |
R2_SECRET_KEY: ${{ secrets.R2_SECRET_KEY }} | |
R2_BUCKET_NAME: ${{ secrets.R2_BUCKET_NAME }} | |
R2_ENDPOINT_URL: ${{ secrets.R2_ENDPOINT_URL }} | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
python code/telegram/export_idf_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 }} |