Skip to content

trigger automation for Hugging Face deploy #1

trigger automation for Hugging Face deploy

trigger automation for Hugging Face deploy #1

Workflow file for this run

name: Deploy Backend to Hugging Face
on:
push:
branches:
- main
paths:
- 'backend/**'
workflow_dispatch: # Allows you to manually trigger it from the Actions tab
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # Needed for subtree split
lfs: true # Fetch LFS files like YOLO model weights
- name: Push to Hugging Face
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
# Set up git
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
# Add Hugging Face as a remote
git remote add hf https://chinmaygawad:$HF_TOKEN@huggingface.co/spaces/chinmaygawad/nutrivision-backend
# Create a new branch containing ONLY the contents of the "backend" directory
git subtree split --prefix backend -b hf-deploy
# Push that branch to the "main" branch of your Hugging Face Space
git push --force hf hf-deploy:main