Skip to content

Commit 68f3c6e

Browse files
authored
Using CircleCI to keep your git repo in sync with Hugging Face spaces (#1101)
* PR adds documentation describing how to use CircleCI to keep your vcs git repo in sync with your Hugging Face space * Remove extra commit from the doc * Added information about CCI and CCI workflows * Adding link to Advanced topics section * Added link to toc * Updated link to HF profile
1 parent 09dd417 commit 68f3c6e

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

docs/hub/_toctree.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@
227227
title: More ways to create Spaces
228228
- local: spaces-github-actions
229229
title: Managing Spaces with Github Actions
230+
- local: spaces-circleci
231+
title: Managing Spaces with CircleCI Workflows
230232
- local: spaces-sdks-python
231233
title: Custom Python Spaces
232234
- local: spaces-add-to-arxiv

docs/hub/spaces-advanced.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
- [Using OpenCV in Spaces](./spaces-using-opencv)
66
- [More ways to create Spaces](./spaces-more-ways-to-create)
77
- [Managing Spaces with Github Actions ](./spaces-github-actions)
8+
- [Managing Spaces with CircleCI Workflows ](./spaces-circleci)
89
- [How to Add a Space to ArXiv ](./spaces-add-to-arxiv)

docs/hub/spaces-circleci.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Managing Spaces with CircleCI Workflows
2+
3+
You can keep your app in sync with your GitHub repository with a **CircleCI workflow**.
4+
5+
[CircleCI](https://circleci.com) is a continuous integration and continuous delivery (CI/CD) platform that helps automate the software development process. A [CircleCI workflow](https://circleci.com/docs/workflows/) is a set of automated tasks defined in a configuration file, orchestrated by CircleCI, to streamline the process of building, testing, and deploying software applications.
6+
7+
*Note: 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 [BFG Repo-Cleaner](https://rtyley.github.io/bfg-repo-cleaner/) to remove any large files from your history. BFG Repo-Cleaner will keep a local copy of your repository as a backup.*
8+
9+
First, set up your GitHub repository and Spaces app together. Add your Spaces app as an additional remote to your existing Git repository.
10+
11+
```bash
12+
git remote add space https://huggingface.co/spaces/HF_USERNAME/SPACE_NAME
13+
```
14+
15+
Then force push to sync everything for the first time:
16+
17+
```bash
18+
git push --force space main
19+
```
20+
21+
Next, set up a [CircleCI workflow](https://circleci.com/docs/workflows/) to push your `main` git branch to Spaces.
22+
23+
In the example below:
24+
25+
* Replace `HF_USERNAME` with your username and `SPACE_NAME` with your Space name.
26+
* [Create a context in CircleCI](https://circleci.com/docs/contexts/) and add an env variable into it called *HF_PERSONAL_TOKEN* (you can give it any name, use the key you create in place of HF_PERSONAL_TOKEN) and the value as your Hugging Face API token. You can find your Hugging Face API token under **API Tokens** on [your Hugging Face profile](https://huggingface.co/settings/tokens).
27+
28+
```yaml
29+
version: 2.1
30+
31+
workflows:
32+
main:
33+
jobs:
34+
- sync-to-huggingface:
35+
context:
36+
- HuggingFace
37+
filters:
38+
branches:
39+
only:
40+
- main
41+
42+
jobs:
43+
sync-to-huggingface:
44+
docker:
45+
- image: alpine
46+
resource_class: small
47+
steps:
48+
- run:
49+
name: install git
50+
command: apk update && apk add openssh-client git
51+
- checkout
52+
- run:
53+
name: push to Huggingface hub
54+
command: |
55+
git config user.email "<your-email@here>"
56+
git config user.name "<your-identifier>"
57+
git push -f https://HF_USERNAME:${HF_PERSONAL_TOKEN}@huggingface.co/spaces/HF_USERNAME/SPACE_NAME main
58+
```

0 commit comments

Comments
 (0)