File: deploy-latest.yml

package info (click to toggle)
datasette 0.65.2-2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 4,260 kB
  • sloc: python: 28,661; javascript: 10,089; sh: 71; makefile: 47; ansic: 26
file content (87 lines) | stat: -rw-r--r-- 2,833 bytes parent folder | download | duplicates (2)
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
name: Deploy latest.datasette.io

on:
  push:
    branches:
      - main

permissions:
  contents: read

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - name: Check out datasette
      uses: actions/checkout@v5
    - name: Set up Python
      uses: actions/setup-python@v6
      with:
        python-version: "3.11"
    - uses: actions/cache@v4
      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
    - id: auth
      name: Authenticate to Google Cloud
      uses: google-github-actions/auth@v2
      with:
        credentials_json: ${{ secrets.GCP_SA_KEY }}
    - name: Set up Cloud SDK
      uses: google-github-actions/setup-gcloud@v3
    - 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" \
            --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