Skip to content

Merge pull request #24 from anasahmed07/004-minikube-k8s-deployment #6

Merge pull request #24 from anasahmed07/004-minikube-k8s-deployment

Merge pull request #24 from anasahmed07/004-minikube-k8s-deployment #6

name: Deploy Backend to Hugging Face Spaces
on:
push:
branches:
- main
paths:
- 'backend/**'
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
- name: Push to Hugging Face Spaces
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
# REPLACE WITH YOUR SPACE NAME (e.g., username/space-name)
HF_SPACE: ${{ secrets.HF_BACKEND_SPACE_NAME }}
run: |
if [ -z "$HF_SPACE" ]; then
echo "Error: HF_SPACE secret is not set."
exit 1
fi
# Configure git to allow pushing
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
# Force push to handle cases where the remote is ahead or diverged
# using git subtree split to create a synthetic root from the backend folder
git push https://oauth2:$HF_TOKEN@huggingface.co/spaces/$HF_SPACE $(git subtree split --prefix backend main):main --force