Skip to content

Update Chess Knowledge Base #276

Update Chess Knowledge Base

Update Chess Knowledge Base #276

Workflow file for this run

name: Update Chess Knowledge Base
permissions:
contents: write
on:
# Run daily at 6:00 UTC
schedule:
- cron: '0 6 * * *'
# Allow manual trigger
workflow_dispatch:
inputs:
months:
description: 'Number of months to fetch (leave empty for all)'
required: false
default: ''
skip_fetch:
description: 'Skip fetching new games'
required: false
default: 'false'
enable_lichess:
description: 'Enable Lichess analysis (slower, requires token)'
required: false
default: 'false'
jobs:
update:
runs-on: ubuntu-latest
steps:
# Checkout repository
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: true
fetch-depth: 0
# Setup Python
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
# Cache pip dependencies
- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
# Install dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests python-chess
# Cache games data (to avoid re-fetching everything)
- name: Cache games data
uses: actions/cache@v4
with:
path: data/games_cache.json
key: games-cache-${{ secrets.CHESS_USERNAME }}-${{ hashFiles('data/games_cache.json') }}
restore-keys: |
games-cache-${{ secrets.CHESS_USERNAME }}-
# Run main script
- name: Run Chess Knowledge Base update
env:
CHESS_USERNAME: ${{ secrets.CHESS_USERNAME }}
LICHESS_TOKEN: ${{ secrets.LICHESS_TOKEN }}
run: |
ARGS=""
if [ "${{ github.event.inputs.months }}" != "" ]; then
ARGS="$ARGS --months ${{ github.event.inputs.months }}"
fi
if [ "${{ github.event.inputs.skip_fetch }}" == "true" ]; then
ARGS="$ARGS --skip-fetch"
fi
if [ "${{ github.event.inputs.enable_lichess }}" == "true" ]; then
ARGS="$ARGS --enable-lichess"
fi
python scripts/main.py $ARGS
# Commit and push changes
- name: Commit and push if changed
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add -A
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "🤖 Auto-update chess knowledge base
Updated: $(date +'%Y-%m-%d %H:%M:%S UTC')
Username: ${{ secrets.CHESS_USERNAME }}"
git push
fi
# Upload artifacts (for debugging)
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: chess-knowledge-data
path: |
data/*.json
knowledge/*.md
retention-days: 7