Actions are defined and enabled in theDocumentation Index
Fetch the complete documentation index at: https://trunk-4cab4936-sam-gutentag-flaky-tests-new-monitors.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
actions section of trunk.yaml.
Here is an example of the actions section of trunk.yaml. If you are curious what your resolved configuration for actions looks like, run trunk config print.
Action Definitions
Now we’ll walk through the process of creating your own action. Actions are required to have aid and run command.
The command will implicitly run relative to your workspace, but you can also specify a run_from if you’d prefer to execute from a sub-directory.
Runtime management
We sandbox action executions and allow you to control the runtime. You can do this by specifying aruntime and packages_file.
You can specify one of our built-in runtimes (node, python, …) or a system runtime that you define. See the runtimes documentation for more information.
For the python and node runtimes, we additionally provide the ability to install a requirements file like requirements.txt or package.json.
Triggers
You can run actions manually, or you can also provide a set of triggers so that actions run in response to some event. They are documented below.Manual runs
You may run an action manually by runningtrunk run <action_id> <args> or trunk actions run <action_id> <args>.
For manually triggered runs, we support the ${@} and ${pwd} variables for template resolution in the run declaration. ${@} will be replaced with the arguments passed to the action, and ${pwd} will be replaced with the directory the action is triggered from.
Time-based triggers
We provide the ability to run actions in the background on a schedule. Undertriggers, you can add one or more schedule entries. For example:
schedule entry should be in the Duration format specified here. The action will be run once per duration.
This is a short-hand for specifying schedule as an object. You can also write:
delay field:
File-based triggers
We provide the ability to run actions automatically based on a file edit. You may provide exact filenames, or globs.my-action will execute if either foo.txt is edited (or created), or if a file inside bar is edited or created.
In case you need to know which file triggered the action, you can use the ${target} variable in the run command.
${target} template may resolve to a space-separated list of files that were simultaneously edited.
Note: We only provide file triggers for files inside of your workspace.
Git hooks
You can also configure Trunk to manage your git hooks. More detail is provided on this in our git hooks reference.Interactivity
Actions can read fromstdin if they are marked as interactive (define interactive: true on the action). Note: this feature is only available for git hooks and manually run actions - since file-triggered and scheduled actions run in the background, you cannot interact with their execution.