import{s as K,n as ss,o as ls}from"../chunks/scheduler.d6170356.js";import{S as ts,i as as,g as p,s as n,r as b,A as ns,h as i,f as t,c as e,j as q,u as E,x as T,k as D,y as es,a,v as J,d as B,t as C,w as d}from"../chunks/index.fcd4cc08.js";import{C as Y}from"../chunks/CodeBlock.7b16bdef.js";import{H as Ms}from"../chunks/Heading.8660bd0e.js";function ps(x){let M,I,f,S,c,N,j,W='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.',Z,r,X="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.",G,o,H,h,V="Then force push to sync everything for the first time:",$,y,F,U,P="Next, set up a GitHub Action to push your main branch to Spaces. In the example below:",v,u,L='<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>',R,m,k,w,O="Finally, create an Action that automatically checks the file size of any new pull request:",z,A,Q,g,_;return c=new Ms({props:{title:"Managing Spaces with Github Actions",local:"managing-spaces-with-github-actions",headingTag:"h1"}}),o=new Y({props:{code:"Z2l0JTIwcmVtb3RlJTIwYWRkJTIwc3BhY2UlMjBodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGc3BhY2VzJTJGSEZfVVNFUk5BTUUlMkZTUEFDRV9OQU1F",highlighted:"git remote add space https://huggingface.co/spaces/HF_USERNAME/SPACE_NAME",wrap:!1}}),y=new Y({props:{code:"Z2l0JTIwcHVzaCUyMC0tZm9y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VSTkFNRSUzQSUyNEhGX1RPS0VOJTQwaHVnZ2luZ2ZhY2UuY28lMkZzcGFjZXMlMkZIRl9VU0VSTkFNRSUyRlNQQUNFX05BTUUlMjBtYWlu",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 Y({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>`,wrap:!1}}),{c(){M=p("meta"),I=n(),f=p("p"),S=n(),b(c.$$.fragment),N=n(),j=p("p"),j.innerHTML=W,Z=n(),r=p("p"),r.textContent=X,G=n(),b(o.$$.fragment),H=n(),h=p("p"),h.textContent=V,$=n(),b(y.$$.fragment),F=n(),U=p("p"),U.textContent=P,v=n(),u=p("ul"),u.innerHTML=L,R=n(),b(m.$$.fragment),k=n(),w=p("p"),w.textContent=O,z=n(),b(A.$$.fragment),Q=n(),g=p("p"),this.h()},l(s){const l=ns("svelte-u9bgzb",document.head);M=i(l,"META",{name:!0,content:!0}),l.forEach(t),I=e(s),f=i(s,"P",{}),q(f).forEach(t),S=e(s),E(c.$$.fragment,s),N=e(s),j=i(s,"P",{"data-svelte-h":!0}),T(j)!=="svelte-tao05s"&&(j.innerHTML=W),Z=e(s),r=i(s,"P",{"data-svelte-h":!0}),T(r)!=="svelte-v3omxn"&&(r.textContent=X),G=e(s),E(o.$$.fragment,s),H=e(s),h=i(s,"P",{"data-svelte-h":!0}),T(h)!=="svelte-1l2mhji"&&(h.textContent=V),$=e(s),E(y.$$.fragment,s),F=e(s),U=i(s,"P",{"data-svelte-h":!0}),T(U)!=="svelte-2yfd0e"&&(U.textContent=P),v=e(s),u=i(s,"UL",{"data-svelte-h":!0}),T(u)!=="svelte-h2gvgn"&&(u.innerHTML=L),R=e(s),E(m.$$.fragment,s),k=e(s),w=i(s,"P",{"data-svelte-h":!0}),T(w)!=="svelte-1en131u"&&(w.textContent=O),z=e(s),E(A.$$.fragment,s),Q=e(s),g=i(s,"P",{}),q(g).forEach(t),this.h()},h(){D(M,"name","hf:doc:metadata"),D(M,"content",is)},m(s,l){es(document.head,M),a(s,I,l),a(s,f,l),a(s,S,l),J(c,s,l),a(s,N,l),a(s,j,l),a(s,Z,l),a(s,r,l),a(s,G,l),J(o,s,l),a(s,H,l),a(s,h,l),a(s,$,l),J(y,s,l),a(s,F,l),a(s,U,l),a(s,v,l),a(s,u,l),a(s,R,l),J(m,s,l),a(s,k,l),a(s,w,l),a(s,z,l),J(A,s,l),a(s,Q,l),a(s,g,l),_=!0},p:ss,i(s){_||(B(c.$$.fragment,s),B(o.$$.fragment,s),B(y.$$.fragment,s),B(m.$$.fragment,s),B(A.$$.fragment,s),_=!0)},o(s){C(c.$$.fragment,s),C(o.$$.fragment,s),C(y.$$.fragment,s),C(m.$$.fragment,s),C(A.$$.fragment,s),_=!1},d(s){s&&(t(I),t(f),t(S),t(N),t(j),t(Z),t(r),t(G),t(H),t(h),t($),t(F),t(U),t(v),t(u),t(R),t(k),t(w),t(z),t(Q),t(g)),t(M),d(c,s),d(o,s),d(y,s),d(m,s),d(A,s)}}}const is='{"title":"Managing Spaces with Github Actions","local":"managing-spaces-with-github-actions","sections":[],"depth":1}';function cs(x){return ls(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ys extends ts{constructor(M){super(),as(this,M,cs,ps,K,{})}}export{ys as component};
