| name: Deploy to HF Spaces | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'backend/**' | |
| - 'Dockerfile' | |
| - '.github/workflows/deploy-hf.yml' | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| lfs: true | |
| - name: Install Git LFS | |
| run: git lfs install && git lfs pull | |
| - name: Push to HF Spaces | |
| env: | |
| HF_USERNAME: ${{ secrets.HF_USERNAME }} | |
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
| run: | | |
| git config user.email "github-actions@github.com" | |
| git config user.name "GitHub Actions" | |
| git remote add hf https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$HF_USERNAME/rescored | |
| git push -f hf main | |
| - name: Test HF Spaces Deployment | |
| run: | | |
| echo "Waiting for deployment to complete..." | |
| sleep 30 | |
| HF_SPACE_URL="https://${{ secrets.HF_USERNAME }}-rescored.hf.space" | |
| curl -f $HF_SPACE_URL/health || echo "Space still deploying, will be ready soon" | |