Update Card Database #6
This file contains 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 Card Database | |
on: | |
schedule: | |
- cron: '0 0 * * 1' # Runs every Monday at midnight | |
workflow_dispatch: # Allows manual triggering | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
update-cards: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Bun | |
uses: oven-sh/setup-bun@v1 | |
- name: Install dependencies | |
run: bun install | |
- name: Download latest Scryfall data | |
run: | | |
# Fetch the bulk data URL for all cards | |
DOWNLOAD_URL=$(curl -s https://api.scryfall.com/bulk-data | jq -r '.data[] | select(.type=="all_cards") | .download_uri') | |
echo "Downloading from: $DOWNLOAD_URL" | |
curl -L -o processing/cards.json "$DOWNLOAD_URL" | |
- name: Process cards | |
run: | | |
cd processing | |
bun process.ts | |
- name: Move processed file | |
run: | | |
rm -f public/cards.json | |
mv processing/processed.json public/cards.json | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
commit-message: "chore: update card database" | |
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | |
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> | |
branch: update-cards | |
delete-branch: true | |
title: 'Update Scryfall card database' | |
body: | | |
Automated update of the Scryfall card database. | |
- Data source: https://api.scryfall.com/bulk-data | |
- Auto-generated by [create-pull-request][1] | |
[1]: https://github.com/peter-evans/create-pull-request | |
labels: | | |
automated | |
dependencies |