invoice_extractor / .github /workflows /push_to_huggingface.yml
github-actions[bot]
Sync from GitHub: 0326ea25edafa877b6e50d9380e8b84ad62476c1
1e91d4e
name: Push to Hugging Face Hub
on:
push:
branches:
- main
- master
jobs:
sync-to-hub:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
lfs: true
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Push to Hugging Face Hub
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
HF_SPACE_NAME: ${{ secrets.HF_SPACE_NAME }}
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
# Install git-lfs
git lfs install
# Clone the HF space or create new directory
git clone https://user:$HF_TOKEN@huggingface.co/spaces/$HF_SPACE_NAME hf_space 2>/dev/null || {
mkdir hf_space
cd hf_space
git init
git remote add origin https://user:$HF_TOKEN@huggingface.co/spaces/$HF_SPACE_NAME
cd ..
}
cd hf_space
# Configure git LFS
git lfs install
git lfs track "*.pt"
git lfs track "*.pth"
git lfs track "*.bin"
git lfs track "*.h5"
git lfs track "*.onnx"
git lfs track "*.safetensors"
# Copy files from the repository (excluding .git and hf_space)
rsync -av --exclude='.git' --exclude='hf_space' ../ .
# Add all files and commit
git add .
git diff-index --quiet HEAD || git commit -m "Sync from GitHub: ${{ github.sha }}"
# Push to Hugging Face
git push origin main --force