Skip to content

Update Card Database #20

Update Card Database

Update Card Database #20

Workflow file for this run

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 Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm install
- name: Download latest Scryfall data
run: |
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
npx tsx process.ts
- name: Move processed file
run: |
rm -f public/cards.json
mv processing/processed.json public/cards.json
echo "{\"lastUpdated\": \"$(date -u +"%Y-%m-%dT%H:%M:%S.000Z")\"}" > public/last-updated.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
- name: Upload logs
if: always()
uses: actions/upload-artifact@v3
with:
name: process-logs
path: processing/process.log