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