-
Notifications
You must be signed in to change notification settings - Fork 2
75 lines (61 loc) · 2.09 KB
/
build_site.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
name: build_site
on:
push:
branches:
- "main"
# rebuild once a day at 7:30 UTC
schedule:
- cron: "30 7 * * *"
jobs:
build:
name: Build the website
runs-on: ubuntu-latest
steps:
- name: "Check out the repo"
uses: actions/checkout@v4
- name: "Cache book data"
uses: "actions/cache@v4"
with:
path: books.json
key: "books-${{ github.sha }}"
restore-keys: "books-"
- name: "Cache cover images"
uses: "actions/cache@v4"
with:
path: covers
key: "covers-${{ github.sha }}"
restore-keys: "covers-"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: "Install dominant_colours"
run: |
curl -L -O 'https://github.com/alexwlchan/dominant_colours/releases/download/v1.1.8/dominant_colours-x86_64-unknown-linux-gnu.tar.gz'
tar -xzf dominant_colours-x86_64-unknown-linux-gnu.tar.gz
chmod +x dominant_colours
mv dominant_colours /usr/local/bin/dominant_colours
- name: "Check it works"
run: dominant_colours screenshot.png
- name: "Install dependencies"
run: pip3 install -r requirements.txt
- name: "Get the book data"
if: github.ref == 'refs/heads/main'
run: python3 get_book_data.py
env:
LIBRARY_CARD_NUMBER: ${{ secrets.LIBRARY_CARD_NUMBER }}
LIBRARY_CARD_PASSWORD: ${{ secrets.LIBRARY_CARD_PASSWORD }}
- name: "Render the data as HTML"
run: python3 render_data_as_html.py
- name: "Install the Netlify CLI"
run: npm install -g netlify-cli
- name: "Deploy to Netlify (preview)"
if: github.ref != 'refs/heads/main'
run: netlify deploy --dir=_html/
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
- name: "Deploy to Netlify (live)"
if: github.ref == 'refs/heads/main'
run: netlify deploy --dir=_html/ --prod
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}