Scrape Songs Data #47
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: Scrape Songs Data | |
| on: | |
| schedule: | |
| - cron: '0 0 */2 * *' | |
| workflow_dispatch: | |
| jobs: | |
| scrape-songs: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install requests beautifulsoup4 lxml | |
| - name: Run scraper | |
| run: python scripts/scrape_fumen_database.py | |
| - name: Check for changes | |
| id: check-diff | |
| run: | | |
| if git diff --quiet songs.json; then | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit and push changes | |
| if: steps.check-diff.outputs.has_changes == 'true' | |
| run: | | |
| git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add songs.json songs_raw.json history/* | |
| git commit -m "chore: scrape songs data" | |
| git push origin main | |