From 45d76b00e13a0e8e2bbb4d76d22a65f35d2665b3 Mon Sep 17 00:00:00 2001 From: lds Date: Thu, 16 Nov 2023 11:31:34 +0100 Subject: [PATCH 1/6] PR adds documentation describing how to use CircleCI to keep your vcs git repo in sync with your Hugging Face space --- docs/hub/spaces-circleci.md | 56 +++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 docs/hub/spaces-circleci.md diff --git a/docs/hub/spaces-circleci.md b/docs/hub/spaces-circleci.md new file mode 100644 index 000000000..d310c5008 --- /dev/null +++ b/docs/hub/spaces-circleci.md @@ -0,0 +1,56 @@ +# Managing Spaces with CircleCI Workflows + +You can keep your app in sync with your GitHub repository with a **CircleCI workflow**. + +*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.* + +First, set up your GitHub repository and Spaces app together. Add your Spaces app as an additional remote to your existing Git repository. + +```bash +git remote add space https://huggingface.co/spaces/HF_USERNAME/SPACE_NAME +``` + +Then force push to sync everything for the first time: + +```bash +git push --force space main +``` + +Next, set up a [CircleCI workflow](https://circleci.com/docs/workflows/) to push your `main` git branch to Spaces. In the example below: + +* Replace `HF_USERNAME` with your username and `SPACE_NAME` with your Space name. +* [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. + +```yaml +version: 2.1 + +workflows: + main: + jobs: + - sync-to-huggingface: + context: + - HuggingFace + filters: + branches: + only: + - main + +jobs: + sync-to-huggingface: + docker: + - image: alpine + resource_class: small + steps: + - run: + name: install git + command: apk update && apk add openssh-client git + - checkout + - run: + name: push to Huggingface hub + command: | + git config user.email "" + git config user.name "" + git add -A + git commit -m "Automated push job ${CIRCLE_BRANCH} [skip ci]" --allow-empty + git push -f https://HF_USERNAME:${HF_PERSONAL_TOKEN}@huggingface.co/spaces/HF_USERNAME/SPACE_NAME main +``` \ No newline at end of file From c211e25680f1faa036a7243566970c6524fd4e19 Mon Sep 17 00:00:00 2001 From: lds Date: Fri, 17 Nov 2023 15:38:35 +0100 Subject: [PATCH 2/6] Remove extra commit from the doc --- docs/hub/spaces-circleci.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/hub/spaces-circleci.md b/docs/hub/spaces-circleci.md index d310c5008..8c19f5505 100644 --- a/docs/hub/spaces-circleci.md +++ b/docs/hub/spaces-circleci.md @@ -50,7 +50,5 @@ jobs: command: | git config user.email "" git config user.name "" - git add -A - git commit -m "Automated push job ${CIRCLE_BRANCH} [skip ci]" --allow-empty git push -f https://HF_USERNAME:${HF_PERSONAL_TOKEN}@huggingface.co/spaces/HF_USERNAME/SPACE_NAME main ``` \ No newline at end of file From 7bb71817ae0c6724e7d74f091c5717f1d6a1c1f0 Mon Sep 17 00:00:00 2001 From: lds Date: Fri, 17 Nov 2023 16:24:27 +0100 Subject: [PATCH 3/6] Added information about CCI and CCI workflows --- docs/hub/spaces-circleci.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/hub/spaces-circleci.md b/docs/hub/spaces-circleci.md index 8c19f5505..40efc3c77 100644 --- a/docs/hub/spaces-circleci.md +++ b/docs/hub/spaces-circleci.md @@ -2,6 +2,8 @@ You can keep your app in sync with your GitHub repository with a **CircleCI workflow**. +[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. + *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.* First, set up your GitHub repository and Spaces app together. Add your Spaces app as an additional remote to your existing Git repository. @@ -16,7 +18,9 @@ Then force push to sync everything for the first time: git push --force space main ``` -Next, set up a [CircleCI workflow](https://circleci.com/docs/workflows/) to push your `main` git branch to Spaces. In the example below: +Next, set up a [CircleCI workflow](https://circleci.com/docs/workflows/) to push your `main` git branch to Spaces. + +In the example below: * Replace `HF_USERNAME` with your username and `SPACE_NAME` with your Space name. * [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. From f67d93b72339f4e0fbe14bca33096e648e58430e Mon Sep 17 00:00:00 2001 From: lds Date: Wed, 22 Nov 2023 14:46:38 +0100 Subject: [PATCH 4/6] Adding link to Advanced topics section --- docs/hub/spaces-advanced.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/hub/spaces-advanced.md b/docs/hub/spaces-advanced.md index a15847df7..f988810f2 100644 --- a/docs/hub/spaces-advanced.md +++ b/docs/hub/spaces-advanced.md @@ -5,4 +5,5 @@ - [Using OpenCV in Spaces](./spaces-using-opencv) - [More ways to create Spaces](./spaces-more-ways-to-create) - [Managing Spaces with Github Actions ](./spaces-github-actions) +- [Managing Spaces with CircleCI Workflows ](./spaces-circleci) - [How to Add a Space to ArXiv ](./spaces-add-to-arxiv) From 45b754e925e7cd029d2b37da8560ac13a2130631 Mon Sep 17 00:00:00 2001 From: lds Date: Wed, 22 Nov 2023 23:27:51 +0100 Subject: [PATCH 5/6] Added link to toc --- docs/hub/_toctree.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/hub/_toctree.yml b/docs/hub/_toctree.yml index ad3406ade..880f60ba5 100644 --- a/docs/hub/_toctree.yml +++ b/docs/hub/_toctree.yml @@ -223,6 +223,8 @@ title: More ways to create Spaces - local: spaces-github-actions title: Managing Spaces with Github Actions + - local: spaces-circleci + title: Managing Spaces with CircleCI Workflows - local: spaces-sdks-python title: Custom Python Spaces - local: spaces-add-to-arxiv From 6b0b7711a08307f02052f285aff14edca5c6dbf0 Mon Sep 17 00:00:00 2001 From: lds Date: Wed, 22 Nov 2023 23:31:09 +0100 Subject: [PATCH 6/6] Updated link to HF profile --- docs/hub/spaces-circleci.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/hub/spaces-circleci.md b/docs/hub/spaces-circleci.md index 40efc3c77..07a4c61ce 100644 --- a/docs/hub/spaces-circleci.md +++ b/docs/hub/spaces-circleci.md @@ -23,7 +23,7 @@ Next, set up a [CircleCI workflow](https://circleci.com/docs/workflows/) to push In the example below: * Replace `HF_USERNAME` with your username and `SPACE_NAME` with your Space name. -* [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. +* [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). ```yaml version: 2.1