Merge pull request #11 from ShafathZ/main #35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Sync to HuggingFace Spaces | |
| on: | |
| push: | |
| branches: [ "production" ] | |
| workflow_dispatch: | |
| jobs: | |
| sync-to-hub: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| ref: production | |
| fetch-depth: 0 | |
| lfs: true | |
| - name: Install xet | |
| run: | | |
| curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/huggingface/xet-core/refs/heads/main/git_xet/install.sh | sh | |
| echo "$HOME/.xet/bin" >> $GITHUB_PATH | |
| - name: Set git user for xet security | |
| run: | | |
| git config user.name "github-actions" | |
| git config user.email "actions@github.com" | |
| - name: Convert binaries to xet and Push to HuggingFace | |
| env: | |
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
| run: | | |
| # 1. Install Xet | |
| git xet install | |
| # 2. Create a fresh, empty branch for deployment | |
| # This disconnects from previous history, removing the "binary in history" error | |
| git checkout --orphan deployment-branch | |
| # 3. Unstage everything so we can re-add them properly with Xet | |
| git reset | |
| # 4. Configure Xet tracking | |
| # We do this *before* adding files so Xet handles them correctly | |
| git xet track "anime.db" "static/images/*" | |
| # 5. Add all files | |
| # Since we are in a fresh branch, this adds everything currently on disk | |
| git add . | |
| # 6. Commit and Force Push | |
| git config user.name "github-actions" | |
| git config user.email "actions@github.com" | |
| git commit -m "Deploy to Spaces with Xet" | |
| # Force push to 'main' on Hugging Face | |
| git push --force https://MLDevOps:$HF_TOKEN@huggingface.co/spaces/MLDevOps/CS553_CaseStudy1 HEAD:main |