LeonardoMdSA/Context-aware-NLP-classification-platform-with-MCP
2
1name: Deploy to Hugging Face Space2 3on:4 push:5 branches: [ main ]6 workflow_dispatch:7 8permissions:9 contents: write10 11jobs:12 deploy:13 runs-on: ubuntu-latest14 15 steps:16 - name: Checkout repository17 uses: actions/checkout@v418 with:19 fetch-depth: 020 lfs: true21 22 - name: Configure git user23 run: |24 git config user.name "github-actions[bot]"25 git config user.email "github-actions[bot]@users.noreply.github.com"26 27 - name: Ensure Git LFS is installed28 run: |29 sudo apt-get update30 sudo apt-get install -y git-lfs31 git lfs install32 33 - name: Ensure .gitattributes for images34 run: |35 git lfs track "images/**" || true36 echo "images/** filter=lfs diff=lfs merge=lfs -text" >> .gitattributes || true37 git add .gitattributes || true38 git commit -m "ci: add gitattributes" || true39 40 - name: Prepare repository for pre-deploy commit41 run: |42 git add -A43 git diff --cached --quiet || git commit -m "ci: pre-deploy commit" || echo "no changes"44 45 - name: Build Docker container for HF Spaces46 run: |47 docker build -t hf-space-classifier:latest .48 49 - name: Push to Hugging Face Space (via HTTPS)50 env:51 HF_USERNAME: ${{ secrets.HF_USERNAME }}52 HF_TOKEN: ${{ secrets.HF_TOKEN }}53 HF_SPACE_REPO: ${{ secrets.HF_SPACE_REPO }}54 run: |55 if [ -z "$HF_USERNAME" ] || [ -z "$HF_TOKEN" ] || [ -z "$HF_SPACE_REPO" ]; then56 echo "ERROR: Missing secrets HF_USERNAME, HF_TOKEN, HF_SPACE_REPO"57 exit 158 fi59 60 git remote remove hf-space || true61 git remote add hf-space "https://${HF_USERNAME}:${HF_TOKEN}@huggingface.co/spaces/${HF_SPACE_REPO}.git"62 git push --force hf-space HEAD:main63 64 - name: Done65 run: echo "Pushed to Hugging Face Space"66 