synth-net / .github /workflows /push-to-hf-space.yml
github-actions
Sync from GitHub (CI)
6ca4b94
name: Push to Hugging Face Space
on:
push:
branches: [ main ]
workflow_dispatch:
jobs:
to-hf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0
- name: Prepare staging dir for HF Space
run: |
rm -rf hf_staging
mkdir -p hf_staging
# copy repo contents (excluding Git metadata)
rsync -a --exclude '.git' ./ hf_staging/
cd hf_staging
# 1) Ensure README.md is the HF one (but keep your normal README in GitHub)
if [ -f README_HF.md ]; then
mv -f README_HF.md README.md
fi
# 2) Promote Dockerfile from .devcontainer to root for HF build
if [ -f .devcontainer/Dockerfile ]; then
cp .devcontainer/Dockerfile ./Dockerfile
fi
- name: Push to HuggingFace Space
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }} # GitHub repo secret
HF_SPACE: magnolia-psychometrics/synth-net
run: |
cd hf_staging
git init
git lfs install
git config user.email "[email protected]"
git config user.name "github-actions"
git remote add origin https://huggingface.co/spaces/${HF_SPACE}
git add .
git commit -m "Sync from GitHub (CI)"
# Use token to authenticate
git push --force https://user:${HF_TOKEN}@huggingface.co/spaces/${HF_SPACE} HEAD:main