Configuring Publishing to Staging Target
CrafterCMS supports an intermediate publishing target, named staging
, where the project can be fully exercised with regards to system and integration points. This staging publishing target allows testing of your project. Once validated in staging, items can be pushed live. This staging
publishing target precedes live
.
When staging is setup, the Request Publish and Approve for Publish dialogs gives the user the option to select to which publishing target to publish to:
Users will see live or staging underneath items indicating which publishing target an item has been/would be published to: Pending Approval
, Scheduled For Publish
and Recently Published
Notice the pages published to staging and live with the same time in the above image. When staging is setup, all items will go through staging before going to live. So, if a user approves an item to be published directly to live, it will be published to staging first, then onto live.
Setting Up Staging per Project
Staging is setup per project and by default is not enabled. To enable staging for your project, click on from the Sidebar, then click on Configuration and select Project Configuration from the list.
Under the <published-repository> tags, set <enable-staging-environment> to true
.
1<published-repository> 2 <enable-staging-environment>true</enable-staging-environment> 3</published-repository>
To view your project with respect to the staging preview, we need to set it up for delivery. To setup your project for the staging preview, run the init-site
script and follow the instructions in Setup Engine to Deliver a Project using the staging branch in the options.
./init-site.sh -b staging mysite-staging /path/to/published/repo
Note
Remember that when using private key SSH authentication, the private key path must be set explicitly using
the -k
option. Here’s an example:
init-site -k ~/.ssh/jdoe_key myeditorial ssh://myserver/opt/crater/sites/myeditorial
Syncing Staging with Live
There are times when you need to sync the staging publishing target with the live publishing target. When adding the staging
publishing target to an established project, the live repository is not cloned to the staging repository until an item has been published after setting up staging. There may be some other scenarios, when you might need to sync the staging publishing target with the live publishing target.
To sync the staging target with the live target, simply call the reset-staging
API. See publishResetStaging for more details on the API