# .github/workflows/sync-to-hf.yml name: Sync to Hugging Face hub on: push: branches: [main] workflow_dispatch: jobs: sync-to-hub: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 lfs: true - name: Configure git & Git LFS run: | git config user.name "GitHub Actions" git config user.email "actions@github.com" git lfs install --local - name: Set Space path run: | echo "HF_USERNAME=SCGR" >> $GITHUB_ENV echo "SPACE_NAME=Promptaid_Vision" >> $GITHUB_ENV # Use .netrc so we never print the token in a URL - name: Authenticate to Hugging Face via netrc env: HF_API_KEY: ${{ secrets.HF_API_KEY }} run: | test -n "$HF_API_KEY" || (echo "❌ Missing GitHub secret HF_API_KEY" && exit 1) cat > ~/.netrc <10MB) in working tree (should be none unless via LFS):" find . -type f -size +10M -not -path "./.git/*" -printf "%p\t%k KB\n" || true echo; echo "LFS-tracked patterns:" git lfs track || true echo; echo "LFS objects present locally (should list your media):" git lfs ls-files || true # Get all LFS files from GitHub before mirroring to the Space - name: Fetch LFS objects from origin run: | git lfs fetch --all origin git lfs checkout # materialize pointers -> files (optional but safe) git lfs ls-files # show what LFS will upload # Now upload LFS to the Space and push the refs - name: Push to HF Space run: | set -euo pipefail git remote remove space 2>/dev/null || true git remote add space https://huggingface.co/spaces/${HF_USERNAME}/${SPACE_NAME}.git git lfs push --all space # upload all LFS objects to the Space remote git push space HEAD:main --force