-
Notifications
You must be signed in to change notification settings - Fork 382
Using CircleCI to keep your git repo in sync with Hugging Face spaces #1101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
45d76b0
PR adds documentation describing how to use CircleCI to
lavin-ds c211e25
Remove extra commit from the doc
lavin-ds 7bb7181
Added information about CCI and CCI workflows
lavin-ds f67d93b
Adding link to Advanced topics section
lavin-ds 45b754e
Added link to toc
lavin-ds 6b0b771
Updated link to HF profile
lavin-ds File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # Managing Spaces with CircleCI Workflows | ||
|
|
||
| You can keep your app in sync with your GitHub repository with a **CircleCI workflow**. | ||
lavin-ds marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| [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. | ||
|
|
||
| ```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](https://huggingface.co/settings/tokens). | ||
|
|
||
| ```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 "<your-email@here>" | ||
| git config user.name "<your-identifier>" | ||
| git push -f https://HF_USERNAME:${HF_PERSONAL_TOKEN}@huggingface.co/spaces/HF_USERNAME/SPACE_NAME main | ||
| ``` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.