kopia lustrzana https://github.com/simonw/datasette
85 wiersze
2.8 KiB
YAML
85 wiersze
2.8 KiB
YAML
name: Deploy latest.datasette.io
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out datasette
|
|
uses: actions/checkout@v2
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v2
|
|
with:
|
|
python-version: "3.10"
|
|
- uses: actions/cache@v2
|
|
name: Configure pip caching
|
|
with:
|
|
path: ~/.cache/pip
|
|
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pip-
|
|
- name: Install Python dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
python -m pip install -e .[test]
|
|
python -m pip install -e .[docs]
|
|
python -m pip install sphinx-to-sqlite==0.1a1
|
|
- name: Run tests
|
|
if: ${{ github.ref == 'refs/heads/main' }}
|
|
run: |
|
|
pytest -n auto -m "not serial"
|
|
pytest -m "serial"
|
|
- name: Build fixtures.db
|
|
run: python tests/fixtures.py fixtures.db fixtures.json plugins --extra-db-filename extra_database.db
|
|
- name: Build docs.db
|
|
if: ${{ github.ref == 'refs/heads/main' }}
|
|
run: |-
|
|
cd docs
|
|
sphinx-build -b xml . _build
|
|
sphinx-to-sqlite ../docs.db _build
|
|
cd ..
|
|
- name: Set up the alternate-route demo
|
|
run: |
|
|
echo '
|
|
from datasette import hookimpl
|
|
|
|
@hookimpl
|
|
def startup(datasette):
|
|
db = datasette.get_database("fixtures2")
|
|
db.route = "alternative-route"
|
|
' > plugins/alternative_route.py
|
|
cp fixtures.db fixtures2.db
|
|
- name: Set up Cloud Run
|
|
uses: google-github-actions/setup-gcloud@v0
|
|
with:
|
|
version: '275.0.0'
|
|
service_account_email: ${{ secrets.GCP_SA_EMAIL }}
|
|
service_account_key: ${{ secrets.GCP_SA_KEY }}
|
|
- name: Deploy to Cloud Run
|
|
run: |-
|
|
gcloud config set run/region us-central1
|
|
gcloud config set project datasette-222320
|
|
export SUFFIX="-${GITHUB_REF#refs/heads/}"
|
|
export SUFFIX=${SUFFIX#-main}
|
|
datasette publish cloudrun fixtures.db fixtures2.db extra_database.db \
|
|
-m fixtures.json \
|
|
--plugins-dir=plugins \
|
|
--branch=$GITHUB_SHA \
|
|
--version-note=$GITHUB_SHA \
|
|
--extra-options="--setting template_debug 1 --setting trace_debug 1 --crossdb" \
|
|
--install=pysqlite3-binary \
|
|
--service "datasette-latest$SUFFIX"
|
|
- name: Deploy to docs as well (only for main)
|
|
if: ${{ github.ref == 'refs/heads/main' }}
|
|
run: |-
|
|
# Deploy docs.db to a different service
|
|
datasette publish cloudrun docs.db \
|
|
--branch=$GITHUB_SHA \
|
|
--version-note=$GITHUB_SHA \
|
|
--extra-options="--setting template_debug 1" \
|
|
--service=datasette-docs-latest
|