Skip to content

Fixed the overwrite HF Space README #4

Fixed the overwrite HF Space README

Fixed the overwrite HF Space README #4

name: Deploy to Hugging Face Spaces
on:
push:
branches:
- main
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: false
- name: Prepare deployment files
run: |
# Remove data folder if exists
rm -rf data/
git rm --cached -r data/ 2>/dev/null || true
echo "data/" >> .gitignore
- name: Push to Hugging Face Spaces
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
# Clone HF Space to a clean directory
git clone https://Abeshith:$HF_TOKEN@huggingface.co/spaces/Abeshith/RAG-Project hf-space
# Copy only needed files (excluding README to preserve HF config)
cp -r project/ hf-space/
cp -r templates/ hf-space/
cp -r static/ hf-space/
cp app.py hf-space/
cp Dockerfile hf-space/
cp requirements.txt hf-space/
cp .dockerignore hf-space/
# Push to HF Space
cd hf-space
git add .
git commit -m "Deploy from GitHub Actions" || echo "No changes to commit"
git push origin main