chore: apply WhatsApp theme and icon updates #20
This file contains hidden or 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 Materials & Notify | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'website/*.html' | |
| permissions: | |
| contents: write | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install Dependencies | |
| run: npm install cheerio dotenv | |
| - name: Debug Secrets (Check presence) | |
| env: | |
| BT: ${{ secrets.TELEGRAM_BOT_TOKEN }} | |
| CU: ${{ secrets.TELEGRAM_CHANNEL_USERNAME }} | |
| run: | | |
| if [ -z "$BT" ]; then echo "❌ TELEGRAM_BOT_TOKEN is missing"; else echo "✅ TELEGRAM_BOT_TOKEN is present (length: ${#BT})"; fi | |
| if [ -z "$CU" ]; then echo "❌ TELEGRAM_CHANNEL_USERNAME is missing"; else echo "✅ TELEGRAM_CHANNEL_USERNAME is present (length: ${#CU})"; fi | |
| - name: Save Previous Materials state | |
| run: | | |
| mkdir -p .old_cache | |
| # Try to get the previous version of materials.json if it exists | |
| git show HEAD~1:website/data/materials.json > .old_cache/old_materials.json || echo "{}" > .old_cache/old_materials.json | |
| - name: Extract New Materials | |
| run: node scripts/extract-materials.js | |
| - name: Notify Telegram Channel | |
| env: | |
| BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} | |
| CHANNEL_USERNAME: ${{ secrets.TELEGRAM_CHANNEL_USERNAME }} | |
| run: node scripts/notify-channel.js .old_cache/old_materials.json website/data/materials.json | |
| - name: Commit Updated materials.json | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git add website/data/materials.json | |
| if [ -n "$(git status --porcelain)" ]; then | |
| git commit -m "chore: auto-update materials.json" | |
| git push | |
| else | |
| echo "No changes to commit" | |
| fi |