-
-
Notifications
You must be signed in to change notification settings - Fork 112
73 lines (68 loc) · 2.03 KB
/
update_parts_database.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
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@v4
- 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@v3
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@v4
# delete-artifact
- name: Clean
uses: geekyeggo/delete-artifact@v4
with:
name: github-pages