| name: Sync to Hugging Face Spaces | |
| on: | |
| push: | |
| branches: [main] | |
| jobs: | |
| sync-to-hub: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout GitHub Code | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| lfs: true # Explicitly enable LFS fetching | |
| - name: Push to Hugging Face | |
| env: | |
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
| HF_USERNAME: GSoumyajit2005 | |
| SPACE_NAME: invoice-processor-ml | |
| run: | | |
| # 1. Configure Git | |
| git config --global user.email "actions@github.com" | |
| git config --global user.name "GitHub Actions" | |
| # 2. Add Remote | |
| git remote add space https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME | |
| # 3. Force Push (Overwrite HF with GitHub's clean version) | |
| # We skip the fetch/merge steps because we want GitHub to be the source of truth | |
| git push space main --force |