Note: Only the stack owner, admins and users assigned “Developer” roles have the right to create a Publish Rule in a stack.
When you add a publish rule, you are adding a condition for publishing or unpublishing an entry. Adding a rule includes adding an approver for actions (publish/unpublish) to be performed on the entries of particular content types in specific environments, or the stage at which the entry can be published or unpublished, or adding both approver and stage.
Note: Setting up Publish Rules in your Workflow is optional. The reason Publish Rules is part of the Workflows feature is because publishing and unpublishing form an important part of your overall content workflow.
To set up the Publish Rules, log in to your Contentstack account, and perform the following steps:
- Go to your stack and click on the “Settings” icon on the left navigation panel.
- Select Workflows.
- On the Workflow Settings page, click on Publish Rules.
- Click either on + New Rule button as shown in the image below :
- On the publish rule card that expands, you will see two sections: PARAMETERS and CONDITIONS.
In the PARAMETERS section, select the following options as discussed below:
Note: All the parameters are mandatory.
- Branch(es): Select the branch to which you want to apply this rule. You can select multiple branches.
- Content Type(s): Select All Content Types if you want to apply the publish rule to all content types.
Else, select Specific Content Type(s) to apply the publish rule on particular content type(s). When you select this option, click on Select Content Types, select the content types to which the rule should be applied, and click on Add.
- Language(s): Select the language on which you want to apply this rule. You can select multiple languages.
- Environment: Select any one environment for which you want to set the rule.
- Action: Select on which action (Publish or Unpublish) you want to apply this rule.
- In the Condition(s) section, you need to add at least one condition. You can add both the conditions listed below, but at least one is required.
- Approver(s): Use this option to add Users or Roles as approvers. The entries of the specified content types and languages cannot be published or unpublished without the approval of the users or the users associated with a particular role you add here.
- Workflow stage should be: Select the workflow stage upon which an entry can be published or unpublished.
Note: This field displays stages based on the content type (and, consequently, the applied workflow) you have selected in parameters. If you have selected content types that belong to more than one workflow, then this field would be disabled.
- Once you have made your selections in the above fields, click on Save. This will save your settings for the rule. You can add multiple rules by repeating the above steps.
Note: You cannot add more than one rule for a content type.
To add a publish rule via API, refer to the Create publish rule API request.