Weekly Download #53
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: Weekly Download | |
on: | |
schedule: | |
- cron: "0 0 * * 0" # Every Sunday at 00:00 | |
workflow_dispatch: | |
inputs: | |
card_count: | |
description: 'Number of cards to download (leave empty for all)' | |
required: false | |
type: number | |
jobs: | |
weekly: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python 3.12 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.12.3" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Run Download | |
run: | | |
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ github.event.inputs.card_count }}" ]; then | |
# Convert to integer by removing decimal part | |
card_count=$(echo "${{ github.event.inputs.card_count }}" | awk '{print int($1)}') | |
python ./main.py --card-count $card_count | |
else | |
python ./main.py | |
fi | |
- name: Configure Git | |
run: | | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
- name: Commit changes | |
run: | | |
git add cards/ | |
git add meta.json | |
git diff --quiet && git diff --staged --quiet || (git commit -m "Update dataset and build: $(date +'%Y-%m-%d %H:%M')") | |
- name: Install SSH key | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.ACTION_DEPLOY_KEY }} | |
- name: Push changes | |
run: | | |
git remote set-url origin [email protected]:${{ github.repository }}.git | |
git push origin HEAD:${{ github.ref }} |