| name: Sync to Hugging Face hub | |
| on: | |
| push: | |
| branches: [main] | |
| # to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| jobs: | |
| sync-to-hub: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| lfs: true | |
| - name: Install Hugging Face Hub | |
| run: pip install huggingface-hub | |
| - name: Ensure Space Exists | |
| env: | |
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
| run: | | |
| python -c "from huggingface_hub import create_repo; create_repo(repo_id='mishrabp/edureka', repo_type='space', space_sdk='docker', private=False, exist_ok=True)" | |
| - name: Push to hub | |
| env: | |
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
| run: | | |
| # Create a temporary directory for the clean push | |
| mkdir /tmp/hf_sync | |
| # Sync current files (excluding .git) to the temp dir | |
| rsync -av --exclude '.git' ./ /tmp/hf_sync/ | |
| cd /tmp/hf_sync | |
| # Initialize a fresh, temporary git repo | |
| git init -b main | |
| git config user.name "Hugging Face Sync" | |
| git config user.email "sync@huggingface.co" | |
| # Add all files and commit | |
| git add . | |
| git commit -m "Deploy: Clinical RAG Assistant (Clean Push)" | |
| # Force push the single clean commit to HF | |
| git push --force https://mishrabp:$HF_TOKEN@huggingface.co/spaces/mishrabp/edureka main | |