Files
probably-rendering-one-more…/.gitea/workflows/preview.yml
T
codex-bot 7e104cd660
Unified application CI and deployment / static-checks (push) Successful in 6s
Remote development preview source sync / sync-source (push) Successful in 9s
Unified application CI and deployment / verify-and-release (push) Has been skipped
Apply the workspace schema to the dev preview
2026-11-04 17:28:18 +08:00

61 lines
2.7 KiB
YAML

name: Remote development preview source sync
on:
push:
branches: ['**']
paths:
- 'apps/waterfall-wiki/**'
- 'packages/brand/**'
- 'pnpm-workspace.yaml'
- 'scripts/preview/**'
- '.gitea/workflows/preview.yml'
concurrency:
group: development-preview
cancel-in-progress: false
jobs:
sync-source:
# One preview slot follows one branch. Setup changes use an explicit refresh.
if: gitea.ref == format('refs/heads/{0}', vars.PREVIEW_BRANCH || 'dev')
runs-on: ces-control
timeout-minutes: 10
steps:
- 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 }}
SOURCE_BRANCH: ${{ gitea.ref_name }}
run: |
if [ ! -f /opt/prompt-preview/ready ]; then
bash scripts/preview/init.sh "$PWD" waterfall-wiki-tests:6654a1456bdcef77d83ca84373dc36188e15bd12
fi
bash scripts/preview/sync.sh "$PWD" "$SOURCE_SHA" "$SOURCE_BRANCH"