Skip to content

Creating Actions

This guide walks you through creating your first action in Mantis.

Make sure you have:

  • Access to Mantis Lens UI
  • Appropriate permissions to create actions
  • A clear understanding of what your action should do
  1. Open Lens in your browser
  2. Click Actions in the sidebar
  3. Click the New Action button

Enter the action’s identifying information:

FieldDescriptionExample
NameUnique identifier for the actiondeploy-webapp
Initial VersionStarting version number1.0.0

Choose the type of payload for your action:

TypeUse Case
CommandRun a single binary with structured arguments (e.g., docker)
ScriptRun a script file stored in a storage backend
RestartReboot the target machine

Select how the payload should be executed:

ExecutorPlatformDescription
DefaultCross-platformDirect execution without shell (safest)
ShLinux/macOS (WSL on Windows)POSIX shell
BashLinux/macOS (WSL/Git Bash on Windows)Bash shell scripts
PwshCross-platformPowerShell Core (7+)
ZshLinux/macOS (WSL/MSYS2 on Windows)Z shell, invoked with -f (no user startup files)

A command payload is structured, not a freeform shell line. You provide:

FieldDescriptionExample
BinaryPath to the executable to run (bin)docker
ArgumentsOrdered list of plain-string argumentspull, myregistry/myapp:{{version}}
Working DirectoryOptional directory to run the binary in/opt/myapp

Each argument is a single plain string and is added in order. There are no per-argument Default, Required, or Type fields — arguments are passed directly to the binary.

For the Sh, Bash, Pwsh, and Zsh executors, shell metacharacters are rejected in command arguments to prevent command injection. The following characters are not allowed: ; | & $ ` ( ) { } < > ' " \ ! * ? [ ] # ~ as well as newline and carriage return. This means a command payload cannot chain commands (&&, ;), pipe (|), expand shell variables ($VAR), or use globs. If you need that kind of logic, use a Script payload instead.

For example, instead of a single line like docker pull myregistry/myapp:1.0, configure:

  • Binary: docker
  • Argument 1: pull
  • Argument 2: myregistry/myapp:{{version}}

A script payload references a file in a storage backend — you do not edit the script body inline in the action editor. You provide:

FieldDescription
Storage BackendThe storage backend that holds the script file
File NameThe script file to run
Relative PathOptional path to the file within the storage backend

The script file’s content is not variable-substituted. At runtime, resolved variables are passed to the script as MANTIS_* environment variables (see Variables and Runtime below). The file name, command arguments, and working directory support {{...}} substitution.

Define arguments that are passed to your action’s binary or script:

  1. Click Add Argument
  2. Enter the argument value

Arguments are plain strings appended in order. You can reference a resolved variable in an argument using {{variable_name}} syntax (for example, myregistry/myapp:{{version}}).

Define environment variables for execution:

  1. Click Add Environment Variable
  2. Enter variable name (e.g., API_KEY)
  3. Set value or reference a solution variable

Click Save to create your action.

When a deployment runs, Mantis resolves variables and makes them available to your action in two ways:

  1. {{...}} substitution in command arguments, the script file name, and the working directory. The matching syntaxes are {{variable}} (mustache) and ${variable} (shell-style).
  2. MANTIS_* environment variables injected into the executed process. Each resolved variable is exposed as an uppercased, MANTIS_-prefixed environment variable — for example, the variable version becomes MANTIS_VERSION.

Because a script file’s content is not substituted, the way to read a variable from inside a script is via its MANTIS_* environment variable. For example, a Bash script stored in a backend would read $MANTIS_VERSION rather than {{version}}.

┌─────────────────────────────────────────────────────────┐
│ Create New Action │
├─────────────────────────────────────────────────────────┤
│ │
│ Name: [deploy-webapp ] │
│ Version: [1.0.0 ] │
│ │
│ ───────────────────────────────────────────────────── │
│ │
│ Payload Type: ● Command ○ Script │
│ Executor: [Bash ▼] │
│ │
│ ───────────────────────────────────────────────────── │
│ │
│ Binary: [docker ] │
│ Working Directory: [/opt/myapp ] │
│ │
│ Arguments: │
│ ┌───────────────────────────────────────────────────┐ │
│ │ pull │ │
│ │ myregistry/myapp:{{version}} │ │
│ └───────────────────────────────────────────────────┘ │
│ [+ Add Argument] │
│ │
│ [Cancel] [Save] │
└─────────────────────────────────────────────────────────┘

Name: docker-pull Type: Command Executor: Bash

  • Binary: docker
  • Argument 1: pull
  • Argument 2: {{image}}:{{tag}}

The image and tag variables are substituted into the argument at runtime. Because this is a command payload, the arguments are passed directly to the docker binary — no shell chaining, pipes, or $VAR expansion are permitted.

Name: restart-service Type: Script Executor: Bash

The script file (stored in a storage backend, e.g. restart-service.sh) reads the resolved variable via its MANTIS_* environment variable rather than {{...}} substitution, since script content is not substituted:

#!/bin/bash
set -e
SERVICE="$MANTIS_SERVICE_NAME"
echo "Stopping $SERVICE..."
systemctl stop "$SERVICE"
echo "Starting $SERVICE..."
systemctl start "$SERVICE"
echo "Checking status..."
systemctl status "$SERVICE"

The service_name solution variable is injected into the process as MANTIS_SERVICE_NAME.

Name: deploy-windows-service Type: Script Executor: Pwsh

The script file references resolved variables through MANTIS_* environment variables:

Terminal window
$serviceName = $env:MANTIS_SERVICE_NAME
$sourcePath = $env:MANTIS_SOURCE_PATH
$installPath = $env:MANTIS_INSTALL_PATH
Write-Host "Stopping $serviceName..."
Stop-Service -Name $serviceName -Force -ErrorAction SilentlyContinue
Write-Host "Copying files..."
Copy-Item -Path "$sourcePath\*" -Destination $installPath -Recurse -Force
Write-Host "Starting $serviceName..."
Start-Service -Name $serviceName
Write-Host "Deployment complete!"

Before saving, Mantis validates:

CheckDescription
Slug uniquenessNo other action in scope resolves to the same slug (derived from name)
Version formatValid semantic version
ExecutorMust be one of: sh, bash, pwsh, zsh, default
Required fieldsbin required for Command; storage_id and file_name for Script

Once created, your action:

  1. Appears in the action list
  2. Can be added to sequences
  3. Is exercised by deploying a sequence (or solution) that includes it
  4. Is ready for versioning