Scheduled Wallpaper Scraper #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
| # .github/workflows/scraper.yaml | |
| name: Scheduled Wallpaper Scraper | |
| on: | |
| # FIX: Schedule changed to run every hour on the hour (0 * * * *) UTC time. | |
| schedule: | |
| - cron: '0 * * * *' | |
| # Allows manual running of the workflow from the Actions tab | |
| workflow_dispatch: | |
| jobs: | |
| scrape_and_commit: | |
| runs-on: ubuntu-latest | |
| # FIX: Explicitly grant write permissions to GITHUB_TOKEN for push | |
| permissions: | |
| contents: write | |
| steps: | |
| # 1. Checkout the repository code | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # 2. Set up Python environment | |
| - name: Set up Python 3.10 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| # 3. Install necessary dependencies | |
| - name: Install dependencies | |
| run: | | |
| pip install requests beautifulsoup4 pyyaml | |
| # 4. Run the Python scraping script | |
| - name: Run Scraper | |
| id: scraper_run | |
| run: python scraper.py | |
| continue-on-error: true | |
| # 5. Commit the new images to the repository | |
| - name: Commit files | |
| uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| # UPDATED: Simplified path in the file_pattern | |
| file_pattern: '4uffin/images/scraped/**' | |
| commit_message: | | |
| ${{ steps.scraper_run.outcome == 'success' && '馃 Automated scrape: New wallpapers added.' || '鈿狅笍 Automated scrape: Scraper FAILED, attempting to commit existing files.' }} |