import{S as Vs,i as Ps,s as Ls,e as r,k as i,w as z,t as e,N as Os,c as o,d as l,m as c,a as p,x as Q,h as n,b as j,G as a,g as M,y as Y,L as qs,q as W,o as X,B as x,v as Ds}from"../chunks/vendor-hf-doc-builder.js";import{I as Ks}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as os}from"../chunks/CodeBlock-hf-doc-builder.js";function sl(Gs){let u,V,U,f,v,E,ps,F,Ms,P,y,is,k,cs,hs,b,ys,js,L,S,us,O,d,q,C,Us,D,g,K,I,ms,ss,w,m,fs,H,ws,As,Z,Es,bs,ds,h,gs,T,Ts,Js,R,Bs,Ss,$,Cs,Is,ls,J,as,N,Ns,ts,B,es;return E=new Ks({}),d=new os({props:{code:"Z2l0JTIwcmVtb3RlJTIwYWRkJTIwc3BhY2UlMjBodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGc3BhY2VzJTJGSEZfVVNFUk5BTUUlMkZTUEFDRV9OQU1F",highlighted:"git remote add space https://huggingface.co/spaces/HF_USERNAME/SPACE_NAME"}}),g=new os({props:{code:"Z2l0JTIwcHVzaCUyMC0tZm9yY2UlMjBzcGFjZSUyMG1haW4=",highlighted:"git push --force space main"}}),J=new os({props:{code:"bmFtZSUzQSUyMFN5bmMlMjB0byUyMEh1Z2dpbmclMjBGYWNlJTIwaHViJTBBb24lM0ElMEElMjAlMjBwdXNoJTNBJTBBJTIwJTIwJTIwJTIwYnJhbmNoZXMlM0ElMjAlNUJtYWluJTVEJTBBJTBBJTIwJTIwJTIzJTIwdG8lMjBydW4lMjB0aGlzJTIwd29ya2Zsb3clMjBtYW51YWxseSUyMGZyb20lMjB0aGUlMjBBY3Rpb25zJTIwdGFiJTBBJTIwJTIwd29ya2Zsb3dfZGlzcGF0Y2glM0ElMEElMEFqb2JzJTNBJTBBJTIwJTIwc3luYy10by1odWIlM0ElMEElMjAlMjAlMjAlMjBydW5zLW9uJTNBJTIwdWJ1bnR1LWxhdGVzdCUwQSUyMCUyMCUyMCUyMHN0ZXBzJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwLSUyMHVzZXMlM0ElMjBhY3Rpb25zJTJGY2hlY2tvdXQlNDB2MyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHdpdGglM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmZXRjaC1kZXB0aCUzQSUyMDAlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsZnMlM0ElMjB0cnVlJTBBJTIwJTIwJTIwJTIwJTIwJTIwLSUyMG5hbWUlM0ElMjBQdXNoJTIwdG8lMjBodWIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBlbnYlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBIRl9UT0tFTiUzQSUyMCUyNCU3QiU3QiUyMHNlY3JldHMuSEZfVE9LRU4lMjAlN0QlN0QlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBydW4lM0ElMjBnaXQlMjBwdXNoJTIwaHR0cHMlM0ElMkYlMkZIRl9VU0VSTkFNRSUzQSUyNEhGX1RPS0VOJTQwaHVnZ2luZ2ZhY2UuY28lMkZzcGFjZXMlMkZIRl9VU0VSTkFNRSUyRlNQQUNFX05BTUUlMjBtYWlu",highlighted:`<span class="hljs-attr">name:</span> <span class="hljs-string">Sync</span> <span class="hljs-string">to</span> <span class="hljs-string">Hugging</span> <span class="hljs-string">Face</span> <span class="hljs-string">hub</span>
<span class="hljs-attr">on:</span>
  <span class="hljs-attr">push:</span>
    <span class="hljs-attr">branches:</span> [<span class="hljs-string">main</span>]

  <span class="hljs-comment"># to run this workflow manually from the Actions tab</span>
  <span class="hljs-attr">workflow_dispatch:</span>

<span class="hljs-attr">jobs:</span>
  <span class="hljs-attr">sync-to-hub:</span>
    <span class="hljs-attr">runs-on:</span> <span class="hljs-string">ubuntu-latest</span>
    <span class="hljs-attr">steps:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">uses:</span> <span class="hljs-string">actions/checkout@v3</span>
        <span class="hljs-attr">with:</span>
          <span class="hljs-attr">fetch-depth:</span> <span class="hljs-number">0</span>
          <span class="hljs-attr">lfs:</span> <span class="hljs-literal">true</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">Push</span> <span class="hljs-string">to</span> <span class="hljs-string">hub</span>
        <span class="hljs-attr">env:</span>
          <span class="hljs-attr">HF_TOKEN:</span> <span class="hljs-string">\${{</span> <span class="hljs-string">secrets.HF_TOKEN</span> <span class="hljs-string">}}</span>
        <span class="hljs-attr">run:</span> <span class="hljs-string">git</span> <span class="hljs-string">push</span> <span class="hljs-string">https://HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/HF_USERNAME/SPACE_NAME</span> <span class="hljs-string">main</span>`}}),B=new os({props:{code:"bmFtZSUzQSUyMENoZWNrJTIwZmlsZSUyMHNpemUlMEFvbiUzQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMyUyMG9yJTIwZGlyZWN0bHklMjAlNjBvbiUzQSUyMCU1QnB1c2glNUQlNjAlMjB0byUyMHJ1biUyMHRoZSUyMGFjdGlvbiUyMG9uJTIwZXZlcnklMjBwdXNoJTIwb24lMjBhbnklMjBicmFuY2glMEElMjAlMjBwdWxsX3JlcXVlc3QlM0ElMEElMjAlMjAlMjAlMjBicmFuY2hlcyUzQSUyMCU1Qm1haW4lNUQlMEElMEElMjAlMjAlMjMlMjB0byUyMHJ1biUyMHRoaXMlMjB3b3JrZmxvdyUyMG1hbnVhbGx5JTIwZnJvbSUyMHRoZSUyMEFjdGlvbnMlMjB0YWIlMEElMjAlMjB3b3JrZmxvd19kaXNwYXRjaCUzQSUwQSUwQWpvYnMlM0ElMEElMjAlMjBzeW5jLXRvLWh1YiUzQSUwQSUyMCUyMCUyMCUyMHJ1bnMtb24lM0ElMjB1YnVudHUtbGF0ZXN0JTBBJTIwJTIwJTIwJTIwc3RlcHMlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAtJTIwbmFtZSUzQSUyMENoZWNrJTIwbGFyZ2UlMjBmaWxlcyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHVzZXMlM0ElMjBBY3Rpb25zRGVzayUyRmxmcy13YXJuaW5nJTQwdjIuMCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHdpdGglM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmaWxlc2l6ZWxpbWl0JTNBJTIwMTA0ODU3NjAlMjAlMjMlMjB0aGlzJTIwaXMlMjAxME1CJTIwc28lMjB3ZSUyMGNhbiUyMHN5bmMlMjB0byUyMEhGJTIwU3BhY2Vz",highlighted:`<span class="hljs-attr">name:</span> <span class="hljs-string">Check</span> <span class="hljs-string">file</span> <span class="hljs-string">size</span>
<span class="hljs-attr">on:</span>               <span class="hljs-comment"># or directly \`on: [push]\` to run the action on every push on any branch</span>
  <span class="hljs-attr">pull_request:</span>
    <span class="hljs-attr">branches:</span> [<span class="hljs-string">main</span>]

  <span class="hljs-comment"># to run this workflow manually from the Actions tab</span>
  <span class="hljs-attr">workflow_dispatch:</span>

<span class="hljs-attr">jobs:</span>
  <span class="hljs-attr">sync-to-hub:</span>
    <span class="hljs-attr">runs-on:</span> <span class="hljs-string">ubuntu-latest</span>
    <span class="hljs-attr">steps:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">Check</span> <span class="hljs-string">large</span> <span class="hljs-string">files</span>
        <span class="hljs-attr">uses:</span> <span class="hljs-string">ActionsDesk/lfs-warning@v2.0</span>
        <span class="hljs-attr">with:</span>
          <span class="hljs-attr">filesizelimit:</span> <span class="hljs-number">10485760</span> <span class="hljs-comment"># this is 10MB so we can sync to HF Spaces</span>`}}),{c(){u=r("meta"),V=i(),U=r("h1"),f=r("a"),v=r("span"),z(E.$$.fragment),ps=i(),F=r("span"),Ms=e("Managing Spaces with Github Actions"),P=i(),y=r("p"),is=e("You can keep your app in sync with your GitHub repository with "),k=r("strong"),cs=e("Github Actions"),hs=e(". Remember that for files larger than 10MB, Spaces requires Git-LFS. If you don\u2019t want to use Git-LFS, you may need to review your files and check your history. Use a tool like "),b=r("a"),ys=e("BFG Repo-Cleaner"),js=e(" to remove any large files from your history. BFG Repo-Cleaner will keep a local copy of your repository as a backup."),L=i(),S=r("p"),us=e("First, you should set up your GitHub repository and Spaces app together. Add your Spaces app as an additional remote to your existing Git repository."),O=i(),z(d.$$.fragment),q=i(),C=r("p"),Us=e("Then force push to sync everything for the first time:"),D=i(),z(g.$$.fragment),K=i(),I=r("p"),ms=e("Next, set up a GitHub Action to push your main branch to Spaces. In the example below:"),ss=i(),w=r("ul"),m=r("li"),fs=e("Replace "),H=r("code"),ws=e("HF_USERNAME"),As=e(" with your username and "),Z=r("code"),Es=e("SPACE_NAME"),bs=e(" with your Space name."),ds=i(),h=r("li"),gs=e("Create a "),T=r("a"),Ts=e("Github secret"),Js=e(" with your "),R=r("code"),Bs=e("HF_TOKEN"),Ss=e(". You can find your Hugging Face API token under "),$=r("strong"),Cs=e("API Tokens"),Is=e(" on your Hugging Face profile."),ls=i(),z(J.$$.fragment),as=i(),N=r("p"),Ns=e("Finally, create an Action that automatically checks the file size of any new pull request:"),ts=i(),z(B.$$.fragment),this.h()},l(s){const t=Os('[data-svelte="svelte-1phssyn"]',document.head);u=o(t,"META",{name:!0,content:!0}),t.forEach(l),V=c(s),U=o(s,"H1",{class:!0});var ns=p(U);f=o(ns,"A",{id:!0,class:!0,href:!0});var _s=p(f);v=o(_s,"SPAN",{});var vs=p(v);Q(E.$$.fragment,vs),vs.forEach(l),_s.forEach(l),ps=c(ns),F=o(ns,"SPAN",{});var Fs=p(F);Ms=n(Fs,"Managing Spaces with Github Actions"),Fs.forEach(l),ns.forEach(l),P=c(s),y=o(s,"P",{});var G=p(y);is=n(G,"You can keep your app in sync with your GitHub repository with "),k=o(G,"STRONG",{});var ks=p(k);cs=n(ks,"Github Actions"),ks.forEach(l),hs=n(G,". Remember that for files larger than 10MB, Spaces requires Git-LFS. If you don\u2019t want to use Git-LFS, you may need to review your files and check your history. Use a tool like "),b=o(G,"A",{href:!0,rel:!0});var Hs=p(b);ys=n(Hs,"BFG Repo-Cleaner"),Hs.forEach(l),js=n(G," to remove any large files from your history. BFG Repo-Cleaner will keep a local copy of your repository as a backup."),G.forEach(l),L=c(s),S=o(s,"P",{});var Zs=p(S);us=n(Zs,"First, you should set up your GitHub repository and Spaces app together. Add your Spaces app as an additional remote to your existing Git repository."),Zs.forEach(l),O=c(s),Q(d.$$.fragment,s),q=c(s),C=o(s,"P",{});var Rs=p(C);Us=n(Rs,"Then force push to sync everything for the first time:"),Rs.forEach(l),D=c(s),Q(g.$$.fragment,s),K=c(s),I=o(s,"P",{});var $s=p(I);ms=n($s,"Next, set up a GitHub Action to push your main branch to Spaces. In the example below:"),$s.forEach(l),ss=c(s),w=o(s,"UL",{});var rs=p(w);m=o(rs,"LI",{});var _=p(m);fs=n(_,"Replace "),H=o(_,"CODE",{});var zs=p(H);ws=n(zs,"HF_USERNAME"),zs.forEach(l),As=n(_," with your username and "),Z=o(_,"CODE",{});var Qs=p(Z);Es=n(Qs,"SPACE_NAME"),Qs.forEach(l),bs=n(_," with your Space name."),_.forEach(l),ds=c(rs),h=o(rs,"LI",{});var A=p(h);gs=n(A,"Create a "),T=o(A,"A",{href:!0,rel:!0});var Ys=p(T);Ts=n(Ys,"Github secret"),Ys.forEach(l),Js=n(A," with your "),R=o(A,"CODE",{});var Ws=p(R);Bs=n(Ws,"HF_TOKEN"),Ws.forEach(l),Ss=n(A,". You can find your Hugging Face API token under "),$=o(A,"STRONG",{});var Xs=p($);Cs=n(Xs,"API Tokens"),Xs.forEach(l),Is=n(A," on your Hugging Face profile."),A.forEach(l),rs.forEach(l),ls=c(s),Q(J.$$.fragment,s),as=c(s),N=o(s,"P",{});var xs=p(N);Ns=n(xs,"Finally, create an Action that automatically checks the file size of any new pull request:"),xs.forEach(l),ts=c(s),Q(B.$$.fragment,s),this.h()},h(){j(u,"name","hf:doc:metadata"),j(u,"content",JSON.stringify(ll)),j(f,"id","managing-spaces-with-github-actions"),j(f,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),j(f,"href","#managing-spaces-with-github-actions"),j(U,"class","relative group"),j(b,"href","https://rtyley.github.io/bfg-repo-cleaner/"),j(b,"rel","nofollow"),j(T,"href","https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-an-environment"),j(T,"rel","nofollow")},m(s,t){a(document.head,u),M(s,V,t),M(s,U,t),a(U,f),a(f,v),Y(E,v,null),a(U,ps),a(U,F),a(F,Ms),M(s,P,t),M(s,y,t),a(y,is),a(y,k),a(k,cs),a(y,hs),a(y,b),a(b,ys),a(y,js),M(s,L,t),M(s,S,t),a(S,us),M(s,O,t),Y(d,s,t),M(s,q,t),M(s,C,t),a(C,Us),M(s,D,t),Y(g,s,t),M(s,K,t),M(s,I,t),a(I,ms),M(s,ss,t),M(s,w,t),a(w,m),a(m,fs),a(m,H),a(H,ws),a(m,As),a(m,Z),a(Z,Es),a(m,bs),a(w,ds),a(w,h),a(h,gs),a(h,T),a(T,Ts),a(h,Js),a(h,R),a(R,Bs),a(h,Ss),a(h,$),a($,Cs),a(h,Is),M(s,ls,t),Y(J,s,t),M(s,as,t),M(s,N,t),a(N,Ns),M(s,ts,t),Y(B,s,t),es=!0},p:qs,i(s){es||(W(E.$$.fragment,s),W(d.$$.fragment,s),W(g.$$.fragment,s),W(J.$$.fragment,s),W(B.$$.fragment,s),es=!0)},o(s){X(E.$$.fragment,s),X(d.$$.fragment,s),X(g.$$.fragment,s),X(J.$$.fragment,s),X(B.$$.fragment,s),es=!1},d(s){l(u),s&&l(V),s&&l(U),x(E),s&&l(P),s&&l(y),s&&l(L),s&&l(S),s&&l(O),x(d,s),s&&l(q),s&&l(C),s&&l(D),x(g,s),s&&l(K),s&&l(I),s&&l(ss),s&&l(w),s&&l(ls),x(J,s),s&&l(as),s&&l(N),s&&l(ts),x(B,s)}}}const ll={local:"managing-spaces-with-github-actions",title:"Managing Spaces with Github Actions"};function al(Gs){return Ds(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class rl extends Vs{constructor(u){super();Ps(this,u,al,sl,Ls,{})}}export{rl as default,ll as metadata};
