-
-
Notifications
You must be signed in to change notification settings - Fork 110
96 lines (89 loc) · 2.98 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
---
name: "Update parts database"
on:
schedule: # 2 hours after jlcparts updates their database
- cron: "0 5 * * *"
workflow_dispatch: # allow for manually trigger workflow
jobs:
build_and_update:
name: "Update component database and frontend"
runs-on: ubuntu-22.04
environment: github-pages
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
python3 python3-pip wget zip unzip p7zip-full sqlite3
- name: Maximize build space
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 512
swap-size-mb: 1024
remove-dotnet: 'true'
- name: Free more Space, Found in https://github.com/actions/runner-images/issues/2840#issuecomment-790492173
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Checkout
uses: actions/checkout@v4
- name: Show versions
run: |
sqlite3 --version
python3 --version
python3 -c "import sqlite3; import pprint; db = sqlite3.connect(':memory:'); cursor = db.execute('PRAGMA COMPILE_OPTIONS'); pprint.pprint(cursor.fetchall())"
- 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
VOLUMES=$(7z l cache.zip | grep "Volume Index = " | grep -Eoh "[0-9]+")
for seq in $(seq 1 $VOLUMES); do
CACHE=$(printf '%02d' $seq)
wget -q https://yaqwsx.github.io/jlcparts/data/cache.z$CACHE || 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:
actions: write
contents: write
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