Download scripts/deploy_hf_space.sh from raylim/mosaic: direct link, hf CLI and curl.
- Browser
- Download file 976 Bytes
-
https://huggingface.co/spaces/raylim/mosaic/resolve/main/scripts/deploy_hf_space.sh
- Command line
-
hf download hf://spaces/raylim/mosaic/scripts/deploy_hf_space.sh
-
curl -L -o deploy_hf_space.sh https://huggingface.co/spaces/raylim/mosaic/resolve/main/scripts/deploy_hf_space.sh
976 Bytes
| # 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}" | |