Was this article helpful?
Thanks for your feedback
The seed command in Contentstack CLI allows users to import content to your stack, from GitHub repositories. It's an effective command that can help you to migrate content to your stack with minimal steps.
To import content to your stack, you can choose from the following two sources:
Now let’s import content to your stack by performing the following steps:
Note: By default, this CLI session will work for the app hosted in the North America region. If you want to switch to Europe or Azure North America region, follow the steps mentioned in the Set Region command section.
To use the seed command, you will first have to generate the authtoken. To generate the authtoken, open your terminal, and run the following command to log in to your Contentstack account:
csdx auth:login
It will ask you to provide your email address and password of your Contentstack account. Once you log in successfully, an authtoken will be generated and saved to the CLI session until you log out from this session.
Additional Resource: To learn more about the login command, refer to the Login command section.
To use the seed command, you can choose from the following options to import the content to your stack, as mentioned above.
Note: If you want to upload your stack’s content onto your GitHub repository for other users to import it, refer to the steps mentioned in the upload stack's content on the GitHub section.
Let's discuss the above two options in detail.
In this option, you can import content that Contentstack provides from its GitHub organization. To use this option, run the following command in your terminal:
csdx cm:stacks:seed
After running the above command, it will ask you to provide the following inputs:
Tip: To ensure the above operations are error-free, we recommend that you select the option of creating a new destination stack. This is because the new stack will be empty and you can easily import content to it. If you choose to import content to an existing stack, you first need to ensure that the stack is empty and then proceed with the import operation.
Finally, you’ll get the content imported to the destination stack.
In this option, you can import content from your GitHub repository to your stack. However, first, ensure the content is available on your GitHub repository. To upload content on GitHub, perform the steps specified in the upload stack’s content on GitHub section.
Note: The GitHub repository needs to be public.
To import content from the GitHub repository, run the seed command in the following format:
csdx cm:stacks:seed --repo “<account/repository>”
After running this command, you'll be prompted to select an organization and a stack, as discussed in the option 1 section.
The alternate way of using the plugin is by providing the required parameters after the command in a single line.
Options:
Examples:
csdx cm:stacks:seed --repo “Stackcontent/blog"
Likewise, you can use the above format if the stack content resides in an individual’s GitHub repository by replacing the organization’s name with the individual’s username.
To import content to a specific stack use the following command:
csdx cm:stacks:seed --repo "<account/repository> -k "<stack-uid>"
Use the following command to create a new stack in an organization and import your content:
csdx cm:stacks:seed --repo "<account/repository>" --org "<org-uid>" -n "<stack-name>"
The above command creates a new stack in your organization and imports the content in that stack.
To upload your stack’s content to your recently-created GitHub repository, first, you need to export the stack’s content. To do so, follow these steps:
Note: We assume that you are familiar with GitHub and Git. If not, go through GitHub’s documentation to create and upload files to a GitHub repository.
Before uploading stack content on your GitHub repository, you need to create a public repository in this format: stack-<name>. For example, stack-exportdata, stack-gatsby-website, etc.
csdx auth:loginThis command will ask you to provide your Contentstack account credentials.
csdx cm:stacks:export -k <stack_ApiKey> -d “<path_to_store_content>”For example:
csdx cm:stacks:export -k blt********** -d “C:\Users\Name\Desktop\content\stack”
Note: If the management token is not specified, by default export command uses Auth token.
This command will export your stack’s content and save it to the “stack” folder.Note: To avoid the following error make sure to create a GitHub release and proceed to import content.
Error: Unable to find a release for '<account>/<repository>'
Now any user can import your stack’s content to their stack by performing the steps mentioned in the option 2 section.
Was this article helpful?
Thanks for your feedback