Spaces:
Running on T4

mosaic / scripts /deploy_hf_space.sh
raylim's picture
deploy: 0c4f90a Merge pull request #34 from pathology-data-mining/feature/ux-followups
ff80158
Raw History Blame Contribute Delete
976 Bytes
#!/usr/bin/env bash
# Deploy the current commit to a Hugging Face Space repo.
#
# scripts/deploy_hf_space.sh <git-remote> e.g. hf (production), hf-staging
#
# The GitHub history contains a large blob the Space repo rejects, so the
# Space gets a commit with the same tree on top of the Space's own history.
# Its "Source-Commit:" trailer records the GitHub commit, which the app reports
# as mosaic_commit in every result's provenance (src/mosaic/build_info.py).
set -euo pipefail
remote="${1:?usage: $0 <git-remote>}"
if ! git diff --quiet HEAD -- || [ -n "$(git status --porcelain --untracked-files=no)" ]; then
echo "Commit or stash local changes first." >&2
exit 1
fi
src=$(git rev-parse HEAD)
git fetch -q "$remote"
deploy=$(git commit-tree "HEAD^{tree}" -p "$remote/main" \
-m "deploy: ${src:0:7} $(git log -1 --format=%s HEAD)" \
-m "Source-Commit: $src")
git push "$remote" "$deploy:main"
echo "Deployed ${src:0:7} to $remote as ${deploy:0:7}"