MagicNodes / .github /workflows /hf-mirror.yml
DZRobo
Add step to inject HF metadata into README
b72e135
raw
history blame
2.95 kB
name: Mirror to Hugging Face
on:
push:
branches: [main]
workflow_dispatch:
concurrency:
group: hf-mirror-${{ github.ref }}
cancel-in-progress: true
jobs:
mirror:
runs-on: ubuntu-latest
steps:
- name: Checkout (full history + LFS)
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
- name: Configure git identity
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Ensure LFS objects are present
run: |
git lfs install
# Fetch any missing LFS content referenced by HEAD
git lfs fetch --all || true
git lfs checkout || true
echo "LFS files present:" && git lfs ls-files || true
- name: Track image assets via LFS (mirror-only) and rewrite history
run: |
# Hugging Face requires binary assets (jpg/png) to be stored via LFS.
# We rewrite history locally on the runner so GitHub history remains intact,
# but the mirror on HF receives LFS pointers.
git lfs track "*.jpg" "*.jpeg" "*.png"
git add .gitattributes || true
git commit -m "ci(hf): track images via LFS (mirror-only)" || true
# Rewrite history for all refs so no plain binaries remain in the mirror
git lfs migrate import --everything --yes --include="*.jpg,*.jpeg,*.png,*.webp,*.gif,*.bmp,*.tif,*.tiff"
- name: Inject HF metadata (mirror-only)
run: |
cat > README.hf.md << 'EOF'
---
library_name: comfyui
repo_type: model
license: agpl-3.0
pretty_name: MagicNodes (CADE 2.5, QSilk)
pipeline_tag: text-to-image
tags:
- comfyui
- stable-diffusion
- sdxl
- pipeline
- magicnodes
- zeresfdg
- qsilk
- depth-anything
- render
homepage: https://github.com/1dZb1/MagicNodes
---
EOF
printf "\n" >> README.hf.md
cat README.md >> README.hf.md
mv README.hf.md README.md
git add README.md || true
git commit -m "ci(hf): inject HF metadata" || true
- name: Push to HF mirror
env:
HF_USERNAME: ${{ secrets.HF_USERNAME }}
HF_TOKEN: ${{ secrets.HF_TOKEN }}
HF_REPO: MagicNodes
run: |
if [ -z "${HF_USERNAME}" ] || [ -z "${HF_TOKEN}" ]; then
echo "HF secrets are missing. Set HF_USERNAME and HF_TOKEN in repo secrets." >&2
exit 1
fi
git lfs install || true
git remote add hf "https://${HF_USERNAME}:${HF_TOKEN}@huggingface.co/${HF_USERNAME}/${HF_REPO}.git" 2>/dev/null || true
# Mirror current branch to HF main
git push --force --prune hf HEAD:main