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. Open the Deployment group in the top navigation, then the Actions pill
  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 7 (pwsh), else Windows PowerShell 5.1
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 the Binary field (and in a script payload’s file path), because those name what actually runs. The characters not allowed there are: ; | & $ ` ( ) { } < > ' " \ ! * ? [ ] # ~ as well as newline and carriage return.

Arguments are not character-checked. They are single-quoted before the shell line is built, which makes a metacharacter inert rather than rejecting it — so a deployment variable may legitimately contain $, &, a quote or the #{ ... } braces of a template. The consequence is the same either way: an argument cannot chain commands (&&, ;), pipe (|), expand shell variables ($VAR) or glob, because the shell sees it as one literal string. 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 name, content, arguments, working directory and declared environment variable values are templates, and resolved non-sensitive variables are also passed to the script as MANTIS_* environment variables (see Variables and Runtime below).

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 as #{variable_name} (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. #{...} templates in command arguments, the working directory, and a script’s file name and content. A template can apply filters and conditions and read the Mantis.* system variables; see Variables.
  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.

Inside a script, #{version} and $MANTIS_VERSION reach the same value. A sensitive variable is not in the MANTIS_* set; see Sensitive Variables for how a script receives one.

┌─────────────────────────────────────────────────────────┐
│ Create New Action │
├─────────────────────────────────────────────────────────┤
│ │
│ Name: [deploy-webapp ] │
│ Version: [1.0.0 ] │
│ │
│ ───────────────────────────────────────────────────── │
│ │
│ Payload Type: [ Command ▼ ] │
│ 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 from its MANTIS_* environment variable:

#!/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