Certificates-Generator / deploy-to-huggingface.ps1
saifisvibin's picture
Configure for Hugging Face Spaces deployment with Docker
530365a
# Hugging Face Deployment Script
# Run this script to deploy to Hugging Face Spaces
Write-Host "Deploying Certificate Generator to Hugging Face Spaces" -ForegroundColor Cyan
Write-Host ""
# Step 1: Backup and replace README
Write-Host "Step 1: Preparing README for Hugging Face..." -ForegroundColor Yellow
if (Test-Path "README.md") {
if (-not (Test-Path "README_ORIGINAL.md")) {
Copy-Item "README.md" "README_ORIGINAL.md"
Write-Host " Backed up original README to README_ORIGINAL.md" -ForegroundColor Green
}
}
Copy-Item "README_HF.md" "README.md" -Force
Write-Host " Using Hugging Face README" -ForegroundColor Green
Write-Host ""
# Step 2: Check Git remote
Write-Host "Step 2: Configuring Git remote..." -ForegroundColor Yellow
$hfRemote = git remote get-url hf 2>$null
if ($LASTEXITCODE -ne 0) {
git remote add hf https://huggingface.co/spaces/VolarisLLC/Certificates-Generator
Write-Host " Added Hugging Face remote" -ForegroundColor Green
} else {
Write-Host " Hugging Face remote already configured: $hfRemote" -ForegroundColor Green
}
Write-Host ""
# Step 3: Stage changes
Write-Host "Step 3: Staging changes..." -ForegroundColor Yellow
git add .
Write-Host " All changes staged" -ForegroundColor Green
Write-Host ""
# Step 4: Show status
Write-Host "Current Git Status:" -ForegroundColor Yellow
git status --short
Write-Host ""
# Step 5: Commit
Write-Host "Step 4: Creating commit..." -ForegroundColor Yellow
$commitMessage = "Configure for Hugging Face Spaces deployment with Docker"
git commit -m $commitMessage
if ($LASTEXITCODE -eq 0) {
Write-Host " Changes committed" -ForegroundColor Green
} else {
Write-Host " No changes to commit (already committed)" -ForegroundColor Cyan
}
Write-Host ""
# Step 6: Push
Write-Host "Step 5: Pushing to Hugging Face..." -ForegroundColor Yellow
Write-Host ""
Write-Host " You'll be prompted for credentials:" -ForegroundColor Cyan
Write-Host " - Username: Your Hugging Face username" -ForegroundColor Cyan
Write-Host " - Password: Your Hugging Face Access Token" -ForegroundColor Cyan
Write-Host " (Generate token at: https://huggingface.co/settings/tokens)" -ForegroundColor Cyan
Write-Host ""
$branch = git branch --show-current
if ($branch -eq "main") {
git push hf main
} elseif ($branch -eq "master") {
git push hf master:main
} else {
git push hf ${branch}:main
}
if ($LASTEXITCODE -eq 0) {
Write-Host ""
Write-Host "Successfully pushed to Hugging Face!" -ForegroundColor Green
Write-Host ""
Write-Host "Next Steps:" -ForegroundColor Cyan
Write-Host " 1. Visit: https://huggingface.co/spaces/VolarisLLC/Certificates-Generator" -ForegroundColor White
Write-Host " 2. Click 'Logs' tab to monitor the build (takes 3-5 minutes)" -ForegroundColor White
Write-Host " 3. Once built, click 'App' tab to test your deployment" -ForegroundColor White
Write-Host ""
Write-Host "Don't forget to verify your secrets in Space Settings:" -ForegroundColor Yellow
Write-Host " - SENDGRID_API_KEY" -ForegroundColor White
Write-Host " - MAIL_FROM_ADDRESS" -ForegroundColor White
Write-Host ""
} else {
Write-Host ""
Write-Host "Push failed. Please check the error above." -ForegroundColor Red
Write-Host ""
Write-Host "Common issues:" -ForegroundColor Yellow
Write-Host " - Invalid credentials (use Access Token, not password)" -ForegroundColor White
Write-Host " - Network connection issues" -ForegroundColor White
Write-Host " - Repository permissions" -ForegroundColor White
Write-Host ""
}