Fetch MAL Dates #37
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: Fetch MAL Dates | |
| on: | |
| schedule: | |
| # Every 12 hours (midnight and noon UTC) | |
| - cron: '0 0,12 * * *' | |
| workflow_dispatch: # Allow manual trigger | |
| permissions: | |
| contents: write | |
| jobs: | |
| fetch-and-commit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.12' | |
| - name: Install dependencies | |
| run: pip install requests | |
| - name: Run fetch_mal_dates.py | |
| env: | |
| MAL_CLIENT_ID: ${{ secrets.MAL_CLIENT_ID }} | |
| run: python fetch_mal_dates.py | |
| - name: Commit and push if changed | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # Check if only the 'fetched' timestamp changed | |
| if git cat-file -e HEAD:mal_dates_cache.json 2>/dev/null; then | |
| OLD_ENTRIES=$(git show HEAD:mal_dates_cache.json | jq -S -c '.entries') | |
| NEW_ENTRIES=$(jq -S -c '.entries' mal_dates_cache.json) | |
| if [ "$OLD_ENTRIES" = "$NEW_ENTRIES" ]; then | |
| echo "No entries changed. Skipping commit." | |
| exit 0 | |
| fi | |
| fi | |
| git add mal_dates_cache.json | |
| # Only commit if there are actual changes | |
| git diff --cached --quiet || git commit -m "chore: update MAL dates cache $(date -u +'%Y-%m-%d %H:%M UTC')" | |
| git pull --rebase | |
| git push |