wony617
Add github action for deployment to space
b090494
name: Deploy to HF Space
on:
push:
branches: [main]
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
lfs: true
- name: Setup LFS & migrate images
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
git lfs install
git lfs track "images/**"
echo "images/** filter=lfs diff=lfs merge=lfs -text" >> .gitattributes
git add .gitattributes
git commit -m "Add images to LFS tracking" || echo "No changes"
# Ensure working directory is clean
git add -A
git diff --cached --quiet || git commit -m "Pre-migrate: commit all changes" || echo "No changes"
git lfs migrate import --include="images/**" --include-ref=refs/heads/main
- name: Deploy to Hugging Face Space
env:
HF_USERNAME: ${{ secrets.HF_USERNAME }}
HF_TOKEN: ${{ secrets.HF_TOKEN }}
HF_SPACE_NAME: ${{ secrets.HF_SPACE_NAME }}
run: |
git remote add space https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$HF_USERNAME/$HF_SPACE_NAME
git push --force space main