-
Notifications
You must be signed in to change notification settings - Fork 96
108 lines (106 loc) · 3.18 KB
/
build.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
97
98
99
100
101
102
103
104
105
106
107
108
name: Build README and deploy Datasette
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v2
# We need full history to introspect created/updated:
with:
fetch-depth: 0
path: main
- name: Checkout til-db
uses: actions/checkout@v2
with:
repository: simonw/til-db
path: til-db
token: ${{ secrets.PERSONAL_ACCESS_TOKEN_FOR_PUSH }}
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.8
- uses: actions/cache@v2
name: Configure pip caching
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-
restore-keys: |
${{ runner.os }}-node-
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r main/requirements.txt
- name: Install npm dependencies
run: sudo npm install -g puppeteer-cli --unsafe-perm=true
- name: Download previous database unless REBUILD in commit message
if: |-
!contains(github.event.head_commit.message, 'REBUILD')
run: curl --fail -o main/tils.db https://raw.githubusercontent.com/simonw/til-db/main/tils.db
continue-on-error: true
- name: Build database
run: |-
cd main
python build_database.py
- name: Soundness check
run: |-
cd main
datasette . --get / | grep "Simon Willison: TIL"
- name: Generate missing screenshots
run: |-
cd main
python generate_screenshots.py
- name: Update README
run: |-
cd main
python update_readme.py --rewrite
cat README.md
- name: Commit and push if README changed
run: |-
cd main
git diff
git config --global user.email "[email protected]"
git config --global user.name "README-bot"
git diff --quiet || (git add README.md && git commit -m "Updated README")
git push
- name: Save tils.db to simonw/til-db
run: |-
cd til-db
cp ../main/tils.db .
git add tils.db
git commit --amend --no-edit
git push --force
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Deploy Datasette using Vercel
env:
NOW_TOKEN: ${{ secrets.NOW_TOKEN }}
run: |-
cd main
datasette publish vercel tils.db \
--token $NOW_TOKEN \
--branch main \
--project simon-til \
--metadata metadata.yaml \
--static static:static \
--install datasette-template-sql \
--install "datasette-atom>=0.7" \
--install datasette-json-html \
--install beautifulsoup4 \
--install datasette-debug-asgi \
--install "datasette-graphql>=0.12" \
--install datasette-media \
--plugins-dir plugins \
--template-dir templates \
--public