MIS_API / .github /workflows /deploy.yml
UdasriHasindu
add CORS middleware
3190f06
Raw
History Blame Contribute Delete
1.31 kB
name: Deploy to Hugging Face Spaces
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
- name: Push to Hugging Face Spaces
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
# Fail immediately on any error
set -euo pipefail
# Validate token exists
if [ -z "$HF_TOKEN" ]; then
echo "❌ Error: HF_TOKEN secret is not set!"
exit 1
fi
# Remove any trailing whitespace from token
HF_TOKEN="$(echo "$HF_TOKEN" | xargs)"
# Add Hugging Face remote with embedded token (URL encoded)
HF_REMOTE="https://huggingface_user:${HF_TOKEN}@huggingface.co/spaces/xplorers/MIS_API"
git remote add hf "$HF_REMOTE" || git remote set-url hf "$HF_REMOTE"
# Push to Hugging Face main branch
echo "🚀 Pushing to Hugging Face Spaces..."
git push -u hf main --force
echo "✅ Successfully deployed to Hugging Face Spaces!"