Skip to content

Deploy demo

Deploy demo #629

Workflow file for this run

name: Deploy demo
on:
workflow_dispatch:
schedule:
- cron: '27 3 * * *'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
cache: pip
cache-dependency-path: setup.py
- name: Install Python dependencies
run: |
pip install github-to-sqlite
# Need latest datasette for --apt-get-install option
pip install https://github.com/simonw/datasette/archive/main.zip
- name: Fetch list of my repos
run: github-to-sqlite repos repos.db simonw dogsheep
- name: Filter to just the repos I want in the demo
run: sqlite-utils repos.db "
delete from repos where full_name not in (
select full_name from repos
where (
full_name like 'simonw/datasette%'
or full_name like 'simonw/%-datasette'
or full_name like 'simonw/sqlite-%'
or full_name like '%-to-sqlite'
or full_name like '%/dogsheep%'
or full_name in ('simonw/museums', 'simonw/til', 'simonw/django-sql-dashboard')
) and full_name not like '%-support' and fork = 0
)"
- name: Git clone my datasette* repos
run: |-
mkdir all
cd all
for line in $(
sqlite-utils ../repos.db "select full_name from repos" --csv --no-headers
)
do
git clone https://github.com/$line --depth 1
done
find .
pwd
cd ..
- name: Create metadata.yml
run: |
echo '
title: datasette-ripgrep demo
about: simonw/datasette-ripgrep
about_url: https://github.com/simonw/datasette-ripgrep
description_html: |-
<style>
form.ripgrep label {
font-weight: normal;
display: inline;
}
</style>
<form class="ripgrep" action="/-/ripgrep" method="get">
<p>
<input type="search" name="pattern" value="">
<input type="submit" value="Search">
</p>
<p><strong>Options:</strong> <label><input type="checkbox" name="literal"> Literal search (not regex)</label> <label><input type="checkbox" name="ignore"> Ignore case</label></p>
<p>
<label><strong>File pattern</strong>: &nbsp;<input type="text" style="max-width: 20em" name="glob" value=""></label>
</p>
<p class="glob-examples">For example <code>*.py</code> or <code>**/templates/**/*.html</code> or <code>datasette/**</code> or </code><code>!setup.py</code>
</p>
</form>
plugins:
datasette-ripgrep:
path: /app/all
time_limit: 5.0
' > metadata.yml
- name: Set up Cloud Run
uses: google-github-actions/setup-gcloud@v0
with:
version: '318.0.0'
service_account_email: ${{ secrets.GCP_SA_EMAIL }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
- name: Deploy demo using Google Cloud Run
run: |-
gcloud config set run/region us-central1
gcloud config set project datasette-222320
datasette publish cloudrun repos.db \
--metadata metadata.yml \
--static all:all \
--install=https://github.com/simonw/datasette-ripgrep/archive/main.zip \
--service datasette-ripgrep \
--apt-get-install ripgrep