-
Notifications
You must be signed in to change notification settings - Fork 0
Custom actions
Salal is designed for one specific task, which is building websites. However, in the process of developing a site, you may want to perform various other utility actions. For example, you might want to deploy your site to a server. For convenience, Salal provides a way to define custom actions that will execute a set of external commands, or a mix of built-in and external commands.
Custom actions are configured by the use of Parameters, specifically the variable action_commands. Here is an example of a project config file defining an action deploy that uses the *nix tool rsync to copy the build directory to a server:
{
"parameters": {
"action_commands" : {
"deploy" : [
{ "type": "external",
"command": "rsync -e \"/usr/bin/ssh\" -av --exclude=/.well-known/ --delete {{paths.profile_build_dir}}/ {{deploy_destination}}"
}
]
},
}
}
The string specifying the command contains two variable references, indicated by text surrounded by {{ and }}. Variable references are replaced by the appropriate parameter values at the time the command is executed. You can include references to any system variable in the command string. In this case, profile_build_dir is a built-in parameter set internally by Salal itself (see Parameters for more information on built-in parameters). In contrast, deploy_destination is not a built-in parameter, so its value would need to be specified in a configuration file. For example, you might have the following in a file config/profiles/production.json:
{
"parameters": {
"deploy_destination": "mary@mynicesite.com:mynicesite.com/production/"
}
}
Here's another example illustrating how you could configure Salal to run a pre-build script before executing the built-in build action:
{
"parameters" : {
"action_commands": {
"build" : [
{ "type": "external", "command": "make -f project.make" },
{ "type": "internal", "command": "build" }
]
}
}
}
- Home
- About Salal
- Installation
- Tutorials
- Core concepts
- Getting more out of Salal
- Advanced topics
- Change log