Skip to main content

Component Actions


Component Actions have replaced Component Scripts. Zarf will still read scripts entries, but will convert them to actions. Component Scripts will be removed in a future release. Please update your package configurations to use Component Actions instead.


To view the example source code, select the Edit this page link below the article and select the parent folder.

This example demonstrates how to define actions within your package that can run either on zarf package create, zarf package deploy or zarf package remove. These actions will be executed with the context that the Zarf binary is executed with.

For more details on component actions, see the component actions documentation.

- name: on-create
# runs during "zarf package create"
# defaults are applied to all actions in this actionSet
dir: ''
env: []
maxRetries: 0
maxTotalSeconds: 30
# runs before the component is created
# on Windows, touch is replaced with New-Item
- cmd: touch test-create-before.txt
# dir is the directory to run the command in
dir: ''
# this environment variable will be set for this action only
- 'thing=stuff'
# the number of times to retry the action if it fails
maxRetries: 0
# the maximum amount of times the action can run before it is killed, including retries
maxTotalSeconds: 30
# determine if actions output should be printed to the console
mute: false
# runs after the component is deployed
- cmd: touch test-create-after.txt

- name: on-deploy-with-dynamic-variable
# runs during "zarf package deploy"
# runs before the component is deployed
# setVariables can be used to set a variable for use in other actions or components (only onDeploy)
- cmd: echo "meow"
- name: CAT_SOUND
# these variables can also (optionally) be marked as sensitive to sanitize them in the Zarf log
sensitive: true
# this action will have access to the variable set in the previous action (only onDeploy)
# NOTE: when including a variable in a command output this will be written to the log regardless of the sensitive setting
# - use `mute` to silence the command output for sensitive variables
- cmd: echo "the cat says ${ZARF_VAR_CAT_SOUND}"
mute: true