Studio

Release Actions

Create custom actions that display alongside the default Content Release actions.

Release Actions lets you customize and control operations users can perform on a content release. When you create a custom release action it will be available in the actions menu in the release overview and details screens.

This is a paid feature

This feature is available in the Growth plan.

Prerequisites:

  • Custom release actions require Sanity Studio v4.7.0 or later.
  • Release actions are part of Content Releases. If you're not using content releases as part of your workflow, they won't apply. Instead, check out document actions.

Limitations:

  • At this time, custom release actions cannot extend or overwrite existing actions.

Create a release action

To set up a new release action component you need to complete the following steps:

  • Define a release action component
  • Register the release action component to the releases.actions array in your Studio's workspace configuration.

In this example, we'll create an action that logs details about the release to the console.

Create an action component

Start by creating an action component. We recommend using an actions directory in your Studio project, or even an actions/releases directory if you plan to have multiple document, field, and release actions.

For this example, we'll create the component in our Studio project in actions/index.ts.

Release actions accept an object containing the release and an array of documents. In this example, the action accesses these parameters and logs details about the release and any included documents.

Add the component to your studio config

Next, import the action component and add it to the releases.actions array in your studio's sanity.config.ts.

Run the action

Now when you run your Studio locally or deploy the changes, you should see the action available from the "..." icon on the release page.

The release action appears in the actions menu

Selectively render actions

You can selectively render actions based on the studio context.

Release context

Retrieve information about the release by accessing the context.release object. In this example, the custom action becomes available only if the release is scheduled and contains documents.

In addition to release.state, you can access release.metadata to check the type, description, and title.

User context

Another common approach to filtering actions is by user role. In this example, the custom action only displays for users with the administrator role.

Interact with built-in release actions

To call one of the built-in actions from within a custom release action, you can use the Sanity client by importing useClient.

In a custom action component:

Then, as with the example earlier, add it to your release actions array in the sanity.config.ts file.

Was this page helpful?