Git LFS fail for Spaces with Github Workflow

I am trying to setup Github Workflow for a Hugging Face space.
But I receive following error message:

remote: -------------------------------------------------------------------------        
remote: Your push was rejected because it contains binary files.        
remote: Please use https://git-lfs.github.com/ to store binary files.        
remote: See also: https://hf.co/docs/hub/adding-a-model#uploading-your-files        
remote: -------------------------------------------------------------------------        
remote: Offending files:        
remote:  - ballon.jpg (ref: refs/heads/main)        
remote:  - fountain.jpg (ref: refs/heads/main)        
remote:  - wolf.jpg (ref: refs/heads/main)        
To https://huggingface.co/spaces/satpalsr/RegNet-Image-Classification
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://huggingface.co/spaces/satpalsr/RegNet-Image-Classification'
Error: Process completed with exit code 1.

Modified Code I tried:

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@v2
        with:
          fetch-depth: 0
          lfs: true
      - name: Checkout LFS objects
        run: git lfs checkout
      - name: Push to hub
        env:
          HF_TOKEN: ${{ secrets.HF_TOKEN }}
        run: git push --force https://satpalsr:$HF_TOKEN@huggingface.co/spaces/satpalsr/RegNet-Image-Classification main

Hey there! As per the error message, the binary files should be tracked with git lfs.

What you can do is

# Track the files being rejected
git lfs track "your_file" # or *.your_extension

# Track things 
git lfs install

Note that if you have commits with those files, it will still be rejected since the binary files are in previous commits without git lfs, so you will need to change that.

1 Like

Not working!
Added these lines & even created a new test space.
Though the .jpg files are tracked successfully, the exact same error message repeats.

To reproduce:

  1. Create a test space at Hugging Face.
  2. Create a repository on Github.
  3. Add a secret HF token in the Github repo.
  4. Add some image files to the Github repo.
  5. Set up the GitHub action workflow.

if the git repo is public, can you zip the whole repo (including .git) and share it somewhere? Thanks!

Hey @julien-c , here is what you need:
Github Repo: https://github.com/satpalsr/HF-workflow
Github repo zip (including .git) : Check DM
Space Link: https://huggingface.co/spaces/satpalsr/workflow-test