name: CI + Deploy to Hugging Face Space on: push: branches: ["main"] workflow_dispatch: jobs: deploy: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Set up Git run: | git config --global user.email "actions@github.com" git config --global user.name "github-actions" - name: Deploy to Hugging Face Space env: HF_TOKEN: ${{ secrets.HF_TOKEN }} HF_SPACE: ${{ secrets.HF_SPACE }} run: | rm -rf hf_space git clone https://user:$HF_TOKEN@huggingface.co/spaces/$HF_SPACE hf_space rsync -av --delete \ --exclude ".git" \ --exclude "hf_space" \ ./ hf_space/ cd hf_space git add . git commit -m "Auto-deploy from GitHub Actions" || echo "No changes to commit" git push