The SSH action allows you to run scripts and commands on your server. For example, you can add a script that will minify JS files and restart your application after the deployment.
Mode 1: Run as script
By default the commands are run in Run as a script mode. You can choose between SH or BASH specific syntax and use Buddy variables and parameters in commands and URLs (see below):
Mode 2: Line by line
If you switch the mode off, the commands will be executed in the non-interactive mode. This means that:
- Each line is executed in the context of the working directory (default: user’s home dir)
- Lines are executed from top to bottom
- Each command should be one separate line
- If a command fails, the next line will not be executed and the action will fail (unless you check ignore errors)
- Use absolute paths: the cd command will not be carried to the next line
- You can use Buddy specific variables and parameters in commands and URLs
- Environment variables between lines are not shared
If you want to use a more complex script, it its advised to call it from the server side (make sure the exit code it returns is correct).
Supported Environment Variables
Buddy populate a number of environment variables during each execution, for example the branch from which you deploy and the ID of the execution. Here is the list of populated variables: