Spaces:
Running
Running
File size: 989 Bytes
6ed91fb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #!/bin/sh
# Publish the current commit of this repository to its Hugging Face Space.
#
# huggingface/sync-space.sh [OWNER/SPACE] default: 4math/tiled-map-builder
#
# Needs git and the hf CLI (pip install -U huggingface_hub), logged in with write access to the
# Space: run "hf auth login" or set HF_TOKEN. The Space then rebuilds from the Dockerfile.
#
# The Space's README.md must start with its YAML card, so the uploaded README is
# huggingface/space-card.md followed by the repository README. Files deleted from the
# repository are deleted from the Space too.
set -eu
SPACE="${1:-4math/tiled-map-builder}"
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
STAGE="$(mktemp -d)"
trap 'rm -rf "$STAGE"' EXIT
git -C "$ROOT" archive HEAD | tar -x -C "$STAGE"
cat "$ROOT/huggingface/space-card.md" "$ROOT/README.md" > "$STAGE/README.md"
hf upload "$SPACE" "$STAGE" . \
--repo-type space \
--delete "*" \
--commit-message "Sync from GitHub $(git -C "$ROOT" rev-parse --short HEAD)"
|