Debian Codegraph @

.github/workflows/deploy-latest.yml

raw
1 name: Deploy latest.datasette.io
2
3 on:
4 push:
5 branches:
6 - main
7
8 permissions:
9 contents: read
10
11 jobs:
12 deploy:
13 runs-on: ubuntu-latest
14 steps:
15 - name: Check out datasette
16 uses: actions/checkout@v7
17 - name: Set up Python
18 uses: actions/setup-python@v7
19 with:
20 python-version: "3.11"
21 - uses: actions/cache@v6
22 name: Configure pip caching
23 with:
24 path: ~/.cache/pip
25 key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
26 restore-keys: |
27 ${{ runner.os }}-pip-
28 - name: Install Python dependencies
29 run: |
30 python -m pip install --upgrade pip
31 python -m pip install -e .[test]
32 python -m pip install -e .[docs]
33 python -m pip install sphinx-to-sqlite==0.1a1
34 - name: Run tests
35 if: ${{ github.ref == 'refs/heads/main' }}
36 run: |
37 pytest -n auto -m "not serial"
38 pytest -m "serial"
39 - name: Build fixtures.db
40 run: python tests/fixtures.py fixtures.db fixtures.json plugins --extra-db-filename extra_database.db
41 - name: Build docs.db
42 if: ${{ github.ref == 'refs/heads/main' }}
43 run: |-
44 cd docs
45 sphinx-build -b xml . _build
46 sphinx-to-sqlite ../docs.db _build
47 cd ..
48 - name: Set up the alternate-route demo
49 run: |
50 echo '
51 from datasette import hookimpl
52
53 @hookimpl
54 def startup(datasette):
55 db = datasette.get_database("fixtures2")
56 db.route = "alternative-route"
57 ' > plugins/alternative_route.py
58 cp fixtures.db fixtures2.db
59 - id: auth
60 name: Authenticate to Google Cloud
61 uses: google-github-actions/auth@v2
62 with:
63 credentials_json: ${{ secrets.GCP_SA_KEY }}
64 - name: Set up Cloud SDK
65 uses: google-github-actions/setup-gcloud@v3
66 - name: Deploy to Cloud Run
67 run: |-
68 gcloud config set run/region us-central1
69 gcloud config set project datasette-222320
70 export SUFFIX="-${GITHUB_REF#refs/heads/}"
71 export SUFFIX=${SUFFIX#-main}
72 datasette publish cloudrun fixtures.db fixtures2.db extra_database.db \
73 -m fixtures.json \
74 --plugins-dir=plugins \
75 --branch=$GITHUB_SHA \
76 --version-note=$GITHUB_SHA \
77 --extra-options="--setting template_debug 1 --setting trace_debug 1 --crossdb" \
78 --service "datasette-latest$SUFFIX"
79 - name: Deploy to docs as well (only for main)
80 if: ${{ github.ref == 'refs/heads/main' }}
81 run: |-
82 # Deploy docs.db to a different service
83 datasette publish cloudrun docs.db \
84 --branch=$GITHUB_SHA \
85 --version-note=$GITHUB_SHA \
86 --extra-options="--setting template_debug 1" \
87 --service=datasette-docs-latest