Documentation 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.
Defining actions that produce notifications
Typically, whatever actions write to stdout are stored in the log file and perhaps shown to the user. However, actions can also produce structured output ifoutput_type is set on the Action Definition to be notification_v1.
In this case, the action should print yaml to output with the following structure:
- The ID can be whatever you want it to be, but generally should be made to match the action ID.
- You may emit multiple notifications per action.
iconandcommandsare used to control notifications display in VSCode.- High-priority notifications are immediately shown to the user in terminal. Low-priority notifications are only shown every 24 hours (These are configurable).
Deleting notifications
Actions can also clear their own notifications. in this case, make the output looks like this:An example
We illustrate the cycle of actions managing their own notifications with the following example. Consider the built-in action fortrunk upgrade - a command that upgrades trunk and a repo’s enabled linters to their most recent versions. We’d like to notify the user of new upgrades once a day. Thus our trunk-upgrade-available action definition looks like this:
trunk upgrade --notify produces a notification that looks like this:
trunk upgrade --notify will produce:
trunk-upgrade-available action runs in the background periodically and produces a notification. The user takes action by running trunk upgrade. Since trunk upgrade modifies .trunk/trunk.yaml, this will again trigger the trunk-upgrade-available action (due to the file trigger). Since there is nothing else to upgrade, trunk upgrade --notify will produce output telling Trunk to delete its notification. Now, the user is no longer shown a notification about available upgrades!