Apply the workspace schema to the dev preview
This commit is contained in:
@@ -21,6 +21,34 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
- name: Apply additive Workspace migration to dev preview
|
||||
if: gitea.ref == 'refs/heads/dev'
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
root=/opt/prompt-preview
|
||||
test -f "$root/ready"
|
||||
exec 8>/var/lock/prompt-preview-sync.lock
|
||||
flock -w 30 8
|
||||
id=$(docker ps -q --filter label=com.docker.compose.project=prompt-preview --filter label=com.docker.compose.service=postgres)
|
||||
[[ "$id" =~ ^[a-f0-9]{12}$ ]]
|
||||
sql=apps/waterfall-wiki/db/018_workspaces.sql
|
||||
previous=$(cat "$root/fingerprint")
|
||||
scratch=$(mktemp -d)
|
||||
trap 'rm -rf "$scratch"' EXIT
|
||||
mkdir -p "$scratch/apps/waterfall-wiki/db" "$scratch/packages/brand"
|
||||
cp pnpm-workspace.yaml "$scratch/"
|
||||
cp apps/waterfall-wiki/{pnpm-lock.yaml,next.config.ts,tsconfig.json,postcss.config.mjs,package.json} "$scratch/apps/waterfall-wiki/"
|
||||
cp packages/brand/package.json "$scratch/packages/brand/"
|
||||
cp apps/waterfall-wiki/db/*.sql "$scratch/apps/waterfall-wiki/db/"
|
||||
rm "$scratch/$sql"
|
||||
candidate=$(node scripts/preview/fingerprint.mjs "$PWD")
|
||||
if [[ "$candidate" == "$previous" ]]; then exit 0; fi
|
||||
test "$(node scripts/preview/fingerprint.mjs "$scratch")" = "$previous"
|
||||
applied=$(docker exec "$id" psql -XAt -v ON_ERROR_STOP=1 -U prompt -d prompt -c "SELECT 1 FROM schema_migrations WHERE version='018_workspaces'")
|
||||
if [[ "$applied" != 1 ]]; then
|
||||
docker exec -i "$id" psql -X -v ON_ERROR_STOP=1 -U prompt -d prompt < "$sql"
|
||||
fi
|
||||
printf '%s\n' "$candidate" > "$root/fingerprint"
|
||||
- name: Initialize once, otherwise synchronize files only
|
||||
env:
|
||||
SOURCE_SHA: ${{ gitea.sha }}
|
||||
|
||||
Reference in New Issue
Block a user