Run a persistent remote development preview
Unified application CI and deployment / static-checks (push) Successful in 5s
Remote development preview source sync / sync-source (push) Failing after 17s
python CI and deployment / static-checks (push) Successful in 4s
Unified application CI and deployment / static-checks (pull_request) Successful in 5s
python CI and deployment / static-checks (pull_request) Successful in 4s
Unified application CI and deployment / verify-and-release (push) Has been skipped
python CI and deployment / verify-and-deploy (push) Has been skipped
Unified application CI and deployment / verify-and-release (pull_request) Has been skipped
python CI and deployment / verify-and-deploy (pull_request) Has been skipped
Unified application CI and deployment / static-checks (push) Successful in 5s
Remote development preview source sync / sync-source (push) Failing after 17s
python CI and deployment / static-checks (push) Successful in 4s
Unified application CI and deployment / static-checks (pull_request) Successful in 5s
python CI and deployment / static-checks (pull_request) Successful in 4s
Unified application CI and deployment / verify-and-release (push) Has been skipped
python CI and deployment / verify-and-deploy (push) Has been skipped
Unified application CI and deployment / verify-and-release (pull_request) Has been skipped
python CI and deployment / verify-and-deploy (pull_request) Has been skipped
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
SOURCE=$(realpath "${1:?checkout directory required}")
|
||||
SHA=${2:?commit SHA required}
|
||||
BRANCH=${3:?branch required}
|
||||
[[ "$SHA" =~ ^[0-9a-f]{40}$ ]] || exit 2
|
||||
ROOT=/opt/prompt-preview
|
||||
exec 8>/var/lock/prompt-preview-sync.lock
|
||||
flock -w 30 8
|
||||
candidate=$(node "$SOURCE/scripts/preview/fingerprint.mjs" "$SOURCE")
|
||||
if [ ! -s "$ROOT/fingerprint" ]; then
|
||||
echo 'Preview is not initialized; run scripts/preview/init.sh once with a verified tooling image' >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ "$(cat "$ROOT/fingerprint")" != "$candidate" ]; then
|
||||
echo 'Preview refresh required: dependencies, startup configuration or database schema changed. No install/restart/migration was performed.' >&2
|
||||
exit 1
|
||||
fi
|
||||
id=$(docker compose -p prompt-preview --env-file "$ROOT/env" -f "$ROOT/compose.yml" ps -q waterfall-wiki)
|
||||
test -n "$id" && test "$(docker inspect --format '{{.State.Running}}' "$id")" = true
|
||||
# No git credentials, dependency folders, compiler output or environment files are copied.
|
||||
rsync -a --checksum --no-times --delete --chown=1000:1000 \
|
||||
--exclude='.git' --exclude='node_modules' --exclude='.next' --exclude='dist' \
|
||||
--exclude='*.tsbuildinfo' --exclude='.env' --exclude='.env.*' --exclude='.gitea' \
|
||||
--exclude='/apps/waterfall-wiki/public/brand/' --exclude='/apps/waterfall-wiki/public/favicon.ico' --exclude='/apps/waterfall-wiki/public/apple-touch-icon.png' "$SOURCE/" "$ROOT/source/"
|
||||
# Keep generated public marks current using file copies only.
|
||||
assets="$ROOT/source/packages/brand/assets"
|
||||
public="$ROOT/source/apps/waterfall-wiki/public"
|
||||
mkdir -p "$public/brand"
|
||||
copy_asset() {
|
||||
cmp -s "$1" "$2" || install -o 1000 -g 1000 -m 0644 "$1" "$2"
|
||||
}
|
||||
for name in logo-light.svg logo-dark.svg icon-dark.svg; do copy_asset "$assets/svg/$name" "$public/brand/$name"; done
|
||||
copy_asset "$assets/icons/favicon.ico" "$public/favicon.ico"
|
||||
copy_asset "$assets/icons/apple-touch-icon.png" "$public/apple-touch-icon.png"
|
||||
SHA="$SHA" BRANCH="$BRANCH" DEST="$ROOT/status/status.json" python3 - <<'META'
|
||||
import os,json,pathlib,datetime
|
||||
destination=pathlib.Path(os.environ['DEST'])
|
||||
temporary=destination.with_suffix('.tmp')
|
||||
temporary.write_text(json.dumps({'sha':os.environ['SHA'],'branch':os.environ['BRANCH'],'syncedAt':datetime.datetime.now(datetime.timezone.utc).isoformat()})+'\n')
|
||||
temporary.chmod(0o644)
|
||||
temporary.replace(destination)
|
||||
META
|
||||
echo "Preview synchronized: $BRANCH $SHA (container $id)"
|
||||
Reference in New Issue
Block a user