Spaces:
Running
Running
File size: 1,138 Bytes
b146445 | 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 27 28 29 30 | # Deploy the current main branch to the Hugging Face Space as a snapshot (without binary files).
# Run from the project folder: powershell -ExecutionPolicy Bypass -File scripts\deploy_hf.ps1
# Only the Space (remote "space") is force-updated. GitHub (origin) is never touched.
param([string]$Remote = "space")
$dirty = git status --porcelain
if ($dirty) {
Write-Host "There are uncommitted changes. Commit them first (git add . ; git commit -m ...)."
$dirty
exit 1
}
$cur = git branch --show-current
if ($cur -ne "main") {
Write-Host "Switch to main first: git checkout main"
exit 1
}
if (git branch --list hf-deploy) { git branch -D hf-deploy | Out-Null }
git checkout --orphan hf-deploy | Out-Null
git rm --cached -q -r --ignore-unmatch -- "*.png" "*.jpg" "*.jpeg" "*.gif" "*.zip"
git commit -q -m ("deploy " + (Get-Date -Format "yyyy-MM-dd HH:mm"))
git push $Remote hf-deploy:main --force
$code = $LASTEXITCODE
git checkout -f main | Out-Null
git branch -D hf-deploy | Out-Null
if ($code -ne 0) { Write-Host "Push failed (exit $code)."; exit $code }
Write-Host "Done. Watch the build in the Space > Logs tab."
|