Skip to content

Update priority sources #34570

Update priority sources

Update priority sources #34570

name: Update priority sources
# Run hourly except when the real update runs
on:
schedule:
- cron: 0 1-5,7-11,13-17,19-23 * * *
push:
branches: [ master ]
paths: [ source/apps/*, source/generate.py, source/requirements.txt, .github/workflows/update-priority.yml ]
workflow_dispatch:
jobs:
run:
runs-on: ubuntu-latest
container: universalteam/db
steps:
- uses: actions/checkout@v6
- name: Delete old pages
run: rm -rf docs/_3ds/* docs/_ds/*
- name: Run generate.py
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
run: |
export PATH=$PATH:/opt/devkitpro/tools/bin
# Check for background images
BG_DIR=source/bg
COUNT=$(ls $BG_DIR | wc -l)
if [ $COUNT -ne 0 ]; then
SELECTED=$(( $(date +%j) / 3 % $COUNT + 1 ))
BG="$BG_DIR/$(ls $BG_DIR | head -n$SELECTED | tail -n1)"
python3 source/generate.py all --priority --background "$BG"
else
python3 source/generate.py all --priority
fi
# Pull origin in case a commit has been done while updating
- name: Pull origin
run: |
git config --global --add safe.directory /__w/db/db
git pull origin master --ff-only
- name: Push changes
run: |
git config user.email "twlbot@flashcarts.net"
git config user.name "TWLBot"
echo "machine github.com" > "$HOME/.netrc"
echo " login TWLBot" >> "$HOME/.netrc"
echo " password ${{ secrets.GITHUB_TOKEN }}" >> "$HOME/.netrc"
echo "machine api.github.com" >> "$HOME/.netrc"
echo " login TWLBot" >> "$HOME/.netrc"
echo " password ${{ secrets.GITHUB_TOKEN }}" >> "$HOME/.netrc"
git checkout master
if git diff --name-only | grep full.json; then
git stage .
if git commit -m "Update priority sources"; then
git push origin master
fi
fi