30 lines
1.9 KiB
Bash
30 lines
1.9 KiB
Bash
#!/usr/bin/env bash
|
|
# Execute on the confirmed ces-control runner, after user-merged code is deployed.
|
|
# Uses the existing deployed auth volume and matching CI image; does not build or deploy.
|
|
set -Eeuo pipefail
|
|
[[ $# -eq 4 ]] || { echo 'Usage: bash scripts/deliver-studio-series.sh series.json image.png provenance.json output-directory'; exit 2; }
|
|
ROOT=$(git rev-parse --show-toplevel)
|
|
INPUT=$(realpath "$1")
|
|
HERO=$(realpath "$2")
|
|
PROVENANCE=$(realpath "$3")
|
|
mkdir -p "$4"
|
|
OUT=$(realpath "$4")
|
|
IMAGE=$(docker inspect --format '{{.Config.Image}}' prompt-waterfall-wiki-1)
|
|
[[ "$IMAGE" =~ ^waterfall-wiki:[0-9a-f]{40}$ ]] || exit 1
|
|
TEST_IMAGE="waterfall-wiki-tests:${IMAGE#waterfall-wiki:}"
|
|
docker image inspect "$TEST_IMAGE" >/dev/null
|
|
chown 1000:1000 "$OUT"
|
|
COMMON=(--rm --volumes-from prompt-waterfall-wiki-1:ro
|
|
--mount "type=bind,src=$ROOT,dst=/delivery,readonly"
|
|
--mount "type=bind,src=$OUT,dst=/output"
|
|
-e AUTH_CONFIG_FILE=/auth/config.json -e AUTH_CHECK_BASE_URL=http://8.211.154.134:18131)
|
|
docker run "${COMMON[@]}" \
|
|
--mount "type=bind,src=$INPUT,dst=/input/series.json,readonly" \
|
|
--mount "type=bind,src=$HERO,dst=/input/hero.png,readonly" \
|
|
--mount "type=bind,src=$PROVENANCE,dst=/input/provenance.json,readonly" \
|
|
--entrypoint node "$TEST_IMAGE" dist/auth-cli.cjs run /delivery/scripts/save-studio-series.mjs /input/series.json /input/hero.png /input/provenance.json /output
|
|
read -r ID REVISION < <(docker run --rm --mount "type=bind,src=$OUT,dst=/output,readonly" --entrypoint node "$TEST_IMAGE" -e "const d=JSON.parse(require('fs').readFileSync('/output/design.json','utf8'));process.stdout.write(d.id+' '+d.revision+'\n')")
|
|
[[ "$ID" =~ ^[0-9a-f-]{36}$ && "$REVISION" =~ ^[1-9][0-9]*$ ]] || exit 1
|
|
docker run "${COMMON[@]}" -e NODE_PATH=/app/node_modules -e "STUDIO_DESIGN_ID=$ID" -e "STUDIO_EXPORT_DIR=/output/revision-$REVISION" \
|
|
--entrypoint node "$TEST_IMAGE" /delivery/scripts/export-studio-series.cjs
|