The seed command in the Contentstack CLI allows you to import content into your stack from GitHub repositories. It helps you migrate content with minimal steps and setup.
You can import content into your stack from the following sources:
To use the seed command, choose one of the following options to import content into your stack.
Note: To upload your stack’s content to a GitHub repository for others to import, refer to the steps in the Upload Stack's Content on GitHub section.
You can import content directly from Contentstack’s GitHub organization using the CLI. To begin, run the following command in your terminal:
csdx cm:stacks:seedAfter running the command, you’ll be prompted to complete the following steps:
Note: You must be an owner or admin of the selected organization.
Additional resource: Refer to the Stack Roles documentation to learn more about permissions.
Tip: To minimize errors, we recommend creating a new destination stack. If importing content into an existing stack, ensure that it is empty.
The content will be imported into the selected destination stack.
You can import content from your GitHub repository into your stack using this option. Before doing so, ensure your GitHub repository contains the content. To upload content, follow the steps in the Upload Stack’s Content on GitHub section.
Note: The GitHub repository must be public.
To import content, run the following seed command:
csdx cm:stacks:seed --repo “<account/repository>”After running this command, you’ll be prompted to select an organization and a stack, as described in the Import from Contentstack’s GitHub Organization section.
Alternatively, you can run the command with all required parameters in a single line.
Options:
Examples:
csdx cm:stacks:seed --repo "Stackcontent/blog"csdx cm:stacks:seed --repo "username/blog"To import content into a specific stack, run:
csdx cm:stacks:seed --repo "<account/repository>" -k "<stack-api-key>"
To create a new stack in your organization and import content, use:
csdx cm:stacks:seed --repo "<account/repository>" --org "<org-uid>" -n "<stack-name>"This command creates a new stack in your organization and imports the content into it.
Before uploading your stack’s content to GitHub, export it using the following steps.
csdx auth:logincsdx cm:stacks:export -k <stack_ApiKey> -d “<path_to_store_content>”Note: If the management token is not specified, the export command uses Auth token by default.
This command exports your stack’s content and saves it to the stack folder.Additional Resource: Refer to this sample repository in Contentstack's GitHub organization to learn the folder structure for uploading content.
Note: To avoid the following error, create a GitHub release before importing 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 Import from a Non-Contentstack GitHub Repository section.