-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreview.yml
More file actions
56 lines (48 loc) · 2.06 KB
/
Copy pathpreview.yml
File metadata and controls
56 lines (48 loc) · 2.06 KB
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
# SQLite preview-environment workflow.
#
# Prerequisites:
# * Your staging app's deploy.yml mounts a host directory (e.g.
# /var/lib/myapp/storage) into the container; that directory contains
# the SQLite file (e.g. /var/lib/myapp/storage/staging.sqlite3).
# * Your per-PR app must mount the SAME directory so it can read the
# cloned file.
# * `sqlite3` is installed on the deploy host: `apt install sqlite3`.
name: Preview environment
on:
pull_request:
types: [opened, synchronize, reopened, closed]
delete:
permissions:
contents: read
packages: write
pull-requests: write
deployments: write
# Cancel a superseded deploy when a new commit lands on the same PR,
# but never cancel a teardown — letting a `closed` event get cancelled
# would leave the preview app + databases orphaned on the host.
concurrency:
group: kamal-previews-${{ github.event.pull_request.number || github.event.ref || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }}
jobs:
preview:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: web-ascender/github-actions-kamal-previews@v1
with:
base-deploy-file: config/deploy.staging.yml
base-secrets-file: .kamal/secrets.staging
domain-suffix: preview.example.com
deploy-host: staging.example.com
database-engine: sqlite
sqlite-source-path: /var/lib/myapp/storage/staging.sqlite3
sqlite-target-path-pattern: /var/lib/myapp/storage/preview-{slug}.sqlite3
# If your app uses Solid Queue / Cache / Cable backed by SQLite,
# list their suffixes here so they're cloned alongside the primary.
sqlite-also-clone: "_queue _cache _cable"
# Tell the per-PR app where its DB lives.
env-overrides: |
DATABASE_URL=sqlite3:///app/storage/preview-{{slug}}.sqlite3
env:
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SSH_KEY }}