Update parts database #154
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 parts database" | |
on: | |
schedule: # 2 hours after jlcparts updates their database | |
- cron: "0 5 * * *" | |
jobs: | |
build_and_update: | |
name: "Update component database and frontend" | |
runs-on: ubuntu-20.04 | |
environment: github-pages | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y --no-install-recommends \ | |
python3 python3-pip wget zip unzip p7zip-full | |
- name: Install python dependencies | |
run: | | |
pip install humanize | |
- name: Update database | |
run: | | |
set -x | |
mkdir -p db_build | |
cd db_build | |
wget -q https://yaqwsx.github.io/jlcparts/data/cache.zip | |
for seq in $(seq 1 9); do | |
wget -q https://yaqwsx.github.io/jlcparts/data/cache.z0$seq || true | |
done | |
7z x cache.zip | |
rm -rf cache.z* | |
ls -lah | |
cd .. | |
# creates the converted database in 80M split-zip files in folder db_build | |
python3 jlcparts_db_convert.py | |
# remove the source db, as we don't want to package that one | |
rm db_build/cache.sqlite3 | |
# some info output for sanity check | |
ls -lah db_build | |
du -cslh db_build | |
- name: Upload pages artifact | |
uses: actions/upload-pages-artifact@v1 | |
with: | |
name: github-pages | |
path: db_build | |
deploy: | |
name: "Deploy" | |
runs-on: ubuntu-20.04 | |
needs: build_and_update | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
# Deploy to the github-pages environment | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v2 | |
# delete-artifact | |
- name: Clean | |
uses: geekyeggo/delete-artifact@v2 | |
with: | |
name: github-pages |