Files
pulse/scripts/ci/check-web-template.sh
T

27 lines
1.1 KiB
Bash
Raw Normal View History

#!/bin/bash
# Fails if public/web_template/{base.css,base.js} differ from LotusGuild/web_template at
# the commit recorded in public/web_template/VERSION. Change the design system upstream,
# then vendor it with scripts/sync-web-template.sh; never edit the copies here.
set -euo pipefail
ROOT=$(cd "$(dirname "$0")/../.." && pwd)
DEST="$ROOT/public/web_template"
UPSTREAM=${WEB_TEMPLATE_RAW_URL:-https://code.lotusguild.org/LotusGuild/web_template/raw/commit}
sha=$(awk '{print $2}' "$DEST/VERSION")
[[ "$sha" =~ ^[0-9a-f]{7,40}$ ]] || { echo "::error::public/web_template/VERSION has no commit sha"; exit 1; }
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
status=0
for f in base.css base.js; do
curl -fsS --retry 2 --max-time 30 -o "$tmp/$f" "$UPSTREAM/$sha/$f"
if cmp -s "$tmp/$f" "$DEST/$f"; then
echo "$f matches web_template@$sha"
else
echo "::error::public/web_template/$f differs from web_template@$sha. Change it upstream and resync with scripts/sync-web-template.sh."
diff -u "$tmp/$f" "$DEST/$f" | head -40 || true
status=1
fi
done
exit $status