Spaces:
Runtime error
Runtime error
File size: 918 Bytes
8fd4e2b | 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 | #!/usr/bin/env bash
# Deploy the current commit to the Hugging Face Space (git remote "space").
#
# Hugging Face rejects binary files committed directly to git, so this pushes a
# deploy commit with the same code minus docs/ (images), on top of the Space's
# current history. GitHub history is left untouched.
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
if [ -n "$(git status --porcelain)" ]; then
echo "Commit your changes first." >&2
exit 1
fi
git fetch -q space
idx="$(mktemp)"
GIT_INDEX_FILE="$idx" git read-tree HEAD
GIT_INDEX_FILE="$idx" git rm -q --cached -r --ignore-unmatch docs
tree="$(GIT_INDEX_FILE="$idx" git write-tree)"
rm -f "$idx"
msg="Deploy $(git rev-parse --short HEAD): $(git log -1 --format=%s)"
commit="$(git commit-tree "$tree" -p space/main -m "$msg")"
git push space "${commit}:refs/heads/main"
echo "Deployed $(git rev-parse --short HEAD) to the Space as ${commit:0:7}."
|