F4bC0d3 commited on
Commit ·
7976b75
1
Parent(s): aadc662
ci: auto-mirror to huggingface.co/spaces/f4b404/hermes on push to main
Browse filesFree-tier HF Spaces don't expose the native 'linked GitHub repository'
feature, so this workflow force-pushes GitHub main onto the Space's
main branch on every push. The Space rebuilds automatically.
Requires HF_TOKEN secret to be set on this repo (write-scope token
from huggingface.co/settings/tokens).
.github/workflows/sync-to-hf-space.yml
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Sync to Hugging Face Space
|
| 2 |
+
|
| 3 |
+
# Mirrors every push to main onto huggingface.co/spaces/f4b404/hermes
|
| 4 |
+
# so the Space rebuilds automatically. Free-tier HF Spaces don't expose
|
| 5 |
+
# the native "linked GitHub repository" feature, so we mirror by force-
|
| 6 |
+
# pushing the GitHub `main` branch to the Space's `main` branch.
|
| 7 |
+
#
|
| 8 |
+
# Required secret: HF_TOKEN — write-scope HF token from
|
| 9 |
+
# https://huggingface.co/settings/tokens
|
| 10 |
+
|
| 11 |
+
on:
|
| 12 |
+
push:
|
| 13 |
+
branches: [main]
|
| 14 |
+
workflow_dispatch:
|
| 15 |
+
|
| 16 |
+
jobs:
|
| 17 |
+
mirror:
|
| 18 |
+
runs-on: ubuntu-latest
|
| 19 |
+
concurrency:
|
| 20 |
+
group: hf-mirror
|
| 21 |
+
cancel-in-progress: false # never abandon a half-pushed mirror
|
| 22 |
+
steps:
|
| 23 |
+
- name: Checkout (full history so HF gets a useful commit graph)
|
| 24 |
+
uses: actions/checkout@v4
|
| 25 |
+
with:
|
| 26 |
+
fetch-depth: 0
|
| 27 |
+
|
| 28 |
+
- name: Identify as the GitHub Actions mirror
|
| 29 |
+
run: |
|
| 30 |
+
git config user.email "github-actions[bot]@users.noreply.github.com"
|
| 31 |
+
git config user.name "github-actions[bot]"
|
| 32 |
+
|
| 33 |
+
- name: Add the HF Space as a git remote
|
| 34 |
+
env:
|
| 35 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 36 |
+
run: |
|
| 37 |
+
if [ -z "$HF_TOKEN" ]; then
|
| 38 |
+
echo "::error::HF_TOKEN secret is not set on this repo. Add it under Settings → Secrets and variables → Actions."
|
| 39 |
+
exit 1
|
| 40 |
+
fi
|
| 41 |
+
# The mirror is force-push because GitHub history may rebase,
|
| 42 |
+
# squash-merge, or include changes the Space repo doesn't have.
|
| 43 |
+
# If you ever edit files via the HF web UI, those edits will be
|
| 44 |
+
# overwritten on the next mirror — treat GitHub as the source of truth.
|
| 45 |
+
git remote add space "https://F4bC0d3:${HF_TOKEN}@huggingface.co/spaces/f4b404/hermes"
|
| 46 |
+
|
| 47 |
+
- name: Push main branch to the HF Space
|
| 48 |
+
run: |
|
| 49 |
+
git push --force space "$(git rev-parse HEAD):refs/heads/main"
|
| 50 |
+
|
| 51 |
+
- name: Report
|
| 52 |
+
if: always()
|
| 53 |
+
run: |
|
| 54 |
+
echo "Mirrored $(git rev-parse --short HEAD) → https://huggingface.co/spaces/f4b404/hermes"
|
| 55 |
+
echo "The Space will start rebuilding within a few seconds."
|