name: Sync Hugging Face Space on: push: branches: - main jobs: sync: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - name: Push to Hugging Face Space env: HF_TOKEN: ${{ secrets.HF_TOKEN }} HF_SPACE: pradyten/pdf-extractor run: | set -euo pipefail if [ -z "${HF_TOKEN}" ]; then echo "HF_TOKEN is not set." exit 1 fi sync_dir="$(mktemp -d)" git ls-files -z | tar --null -T - -cf - | tar -xf - -C "${sync_dir}" find "${sync_dir}" -type f -name "*.pdf" -delete rm -rf "${sync_dir}/sample" cd "${sync_dir}" git init git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add . git commit -m "Sync from GitHub" git remote add hf "https://user:${HF_TOKEN}@huggingface.co/spaces/${HF_SPACE}" git push --force hf HEAD:main