import{s as as,n as ns,o as es}from"../chunks/scheduler.9cda857a.js";import{S as Ms,i as ps,e as p,s as n,c as b,h as is,a as i,d as t,b as e,f as ls,g as T,j as d,k as ts,l as rs,m as a,n as E,t as J,o as B,p as C}from"../chunks/index.003612b0.js";import{C as js}from"../chunks/CopyLLMTxtMenu.44d08a39.js";import{C as V}from"../chunks/CodeBlock.a90632f1.js";import{H as cs,E as os}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.e5cfda8c.js";function hs(L){let M,S,I,N,r,G,j,Z,c,P='You can keep your app in sync with your GitHub repository with <strong>Github Actions</strong>. Remember that for files larger than 10MB, Spaces requires Git-LFS. If you don’t want to use Git-LFS, you may need to review your files and check your history. Use a tool like <a href="https://rtyley.github.io/bfg-repo-cleaner/" rel="nofollow">BFG Repo-Cleaner</a> to remove any large files from your history. BFG Repo-Cleaner will keep a local copy of your repository as a backup.',H,o,O="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.",F,h,v,y,q="Then force push to sync everything for the first time:",x,u,z,m,D="Next, set up a GitHub Action to push your main branch to Spaces. In the example below:",R,U,K='<li>Replace <code>HF_USERNAME</code> with your username and <code>SPACE_NAME</code> with your Space name.</li> <li>Create a <a href="https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-an-environment" rel="nofollow">Github secret</a> with your <code>HF_TOKEN</code>. You can find your Hugging Face API token under <strong>API Tokens</strong> on your Hugging Face profile.</li>',k,w,Q,f,ss="Finally, create an Action that automatically checks the file size of any new pull request:",_,A,Y,g,W,$,X;return r=new js({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),j=new cs({props:{title:"Managing Spaces with Github Actions",local:"managing-spaces-with-github-actions",headingTag:"h1"}}),h=new V({props:{code:"Z2l0JTIwcmVtb3RlJTIwYWRkJTIwc3BhY2UlMjBodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGc3BhY2VzJTJGSEZfVVNFUk5BTUUlMkZTUEFDRV9OQU1F",highlighted:"git remote add space https://huggingface.co/spaces/HF_USERNAME/SPACE_NAME",wrap:!1}}),u=new V({props:{code:"Z2l0JTIwcHVzaCUyMC0tZm9yY2UlMjBzcGFjZSUyMG1haW4=",highlighted:"git push --force space main",wrap:!1}}),w=new V({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>`,wrap:!1}}),A=new V({props:{code:"bmFt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s-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>`,wrap:!1}}),g=new os({props:{source:"https://github.com/huggingface/hub-docs/blob/main/docs/hub/spaces-github-actions.md"}}),{c(){M=p("meta"),S=n(),I=p("p"),N=n(),b(r.$$.fragment),G=n(),b(j.$$.fragment),Z=n(),c=p("p"),c.innerHTML=P,H=n(),o=p("p"),o.textContent=O,F=n(),b(h.$$.fragment),v=n(),y=p("p"),y.textContent=q,x=n(),b(u.$$.fragment),z=n(),m=p("p"),m.textContent=D,R=n(),U=p("ul"),U.innerHTML=K,k=n(),b(w.$$.fragment),Q=n(),f=p("p"),f.textContent=ss,_=n(),b(A.$$.fragment),Y=n(),b(g.$$.fragment),W=n(),$=p("p"),this.h()},l(s){const l=is("svelte-u9bgzb",document.head);M=i(l,"META",{name:!0,content:!0}),l.forEach(t),S=e(s),I=i(s,"P",{}),ls(I).forEach(t),N=e(s),T(r.$$.fragment,s),G=e(s),T(j.$$.fragment,s),Z=e(s),c=i(s,"P",{"data-svelte-h":!0}),d(c)!=="svelte-tao05s"&&(c.innerHTML=P),H=e(s),o=i(s,"P",{"data-svelte-h":!0}),d(o)!=="svelte-v3omxn"&&(o.textContent=O),F=e(s),T(h.$$.fragment,s),v=e(s),y=i(s,"P",{"data-svelte-h":!0}),d(y)!=="svelte-1l2mhji"&&(y.textContent=q),x=e(s),T(u.$$.fragment,s),z=e(s),m=i(s,"P",{"data-svelte-h":!0}),d(m)!=="svelte-2yfd0e"&&(m.textContent=D),R=e(s),U=i(s,"UL",{"data-svelte-h":!0}),d(U)!=="svelte-h2gvgn"&&(U.innerHTML=K),k=e(s),T(w.$$.fragment,s),Q=e(s),f=i(s,"P",{"data-svelte-h":!0}),d(f)!=="svelte-1en131u"&&(f.textContent=ss),_=e(s),T(A.$$.fragment,s),Y=e(s),T(g.$$.fragment,s),W=e(s),$=i(s,"P",{}),ls($).forEach(t),this.h()},h(){ts(M,"name","hf:doc:metadata"),ts(M,"content",ys)},m(s,l){rs(document.head,M),a(s,S,l),a(s,I,l),a(s,N,l),E(r,s,l),a(s,G,l),E(j,s,l),a(s,Z,l),a(s,c,l),a(s,H,l),a(s,o,l),a(s,F,l),E(h,s,l),a(s,v,l),a(s,y,l),a(s,x,l),E(u,s,l),a(s,z,l),a(s,m,l),a(s,R,l),a(s,U,l),a(s,k,l),E(w,s,l),a(s,Q,l),a(s,f,l),a(s,_,l),E(A,s,l),a(s,Y,l),E(g,s,l),a(s,W,l),a(s,$,l),X=!0},p:ns,i(s){X||(J(r.$$.fragment,s),J(j.$$.fragment,s),J(h.$$.fragment,s),J(u.$$.fragment,s),J(w.$$.fragment,s),J(A.$$.fragment,s),J(g.$$.fragment,s),X=!0)},o(s){B(r.$$.fragment,s),B(j.$$.fragment,s),B(h.$$.fragment,s),B(u.$$.fragment,s),B(w.$$.fragment,s),B(A.$$.fragment,s),B(g.$$.fragment,s),X=!1},d(s){s&&(t(S),t(I),t(N),t(G),t(Z),t(c),t(H),t(o),t(F),t(v),t(y),t(x),t(z),t(m),t(R),t(U),t(k),t(Q),t(f),t(_),t(Y),t(W),t($)),t(M),C(r,s),C(j,s),C(h,s),C(u,s),C(w,s),C(A,s),C(g,s)}}}const ys='{"title":"Managing Spaces with Github Actions","local":"managing-spaces-with-github-actions","sections":[],"depth":1}';function us(L){return es(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class gs extends Ms{constructor(M){super(),ps(this,M,us,hs,as,{})}}export{gs as component};
