name: Sync to Hugging Face Space on: push: branches: - main workflow_dispatch: jobs: sync-to-hf: name: Push to HF Space runs-on: ubuntu-latest permissions: contents: read steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 lfs: true - name: Configure Git run: | git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.name "github-actions[bot]" - name: Validate HF_TOKEN env: HF_TOKEN: ${{ secrets.HF_TOKEN }} run: | if [ -z "${HF_TOKEN}" ]; then echo "Error: HF_TOKEN secret is not set." echo "Please add a Hugging Face User Access Token as a repository secret named HF_TOKEN." echo "See: https://huggingface.co/settings/tokens" exit 1 fi - name: Push to Hugging Face Space env: HF_TOKEN: ${{ secrets.HF_TOKEN }} run: | git remote add space https://Abs6187:${HF_TOKEN}@huggingface.co/spaces/Abs6187/TechTrident # Build a clean deployment commit that excludes binary files that are # already present on the HF Space or would be rejected by the pre-receive hook. # - model/: files exceed the 10 MiB per-file limit. # - logs/*.png: binary image files rejected by HF's binary-file policy. # git checkout --orphan keeps all current files staged in the index. git checkout --orphan hf-deploy git rm -rf --cached model/ git rm -rf --cached logs/*.png git commit -m "Sync to Hugging Face Space (model and log images excluded)" git push --force space hf-deploy:main