π Update PPVLand Playlist πΊ #2545
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: "π Update PPVLand Playlist πΊ" | |
| on: | |
| schedule: | |
| - cron: '0 * * * *' # β° Run every hour | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| scrape: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: π₯ Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: π Set up Python 3.11 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: π¦ Install Python dependencies & Playwright | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install playwright urllib3 aiohttp | |
| playwright install firefox | |
| playwright install-deps | |
| - name: π― Run scraping script | |
| run: python ppv.py | |
| - name: πΎ Commit & Safely Push if Playlist Changed | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add PPVLand.m3u8 | |
| if git diff --cached --quiet; then | |
| echo "β No changes to commit" | |
| exit 0 | |
| fi | |
| git commit -m "π Update playlist $(date -u +'%a %b %d %T UTC %Y')" | |
| sleep $((RANDOM % 10 + 5)) | |
| if ! git push origin main; then | |
| echo "β οΈ Push rejected. Trying safe fetch + merge..." | |
| git pull origin main --rebase || { | |
| echo "β Rebase failed. Exiting to avoid corruption." | |
| exit 1 | |
| } | |
| git push origin main || { | |
| echo "β Second push failed. Remote changed again." | |
| exit 1 | |
| } | |
| fi |