Variants
All Comtrya actions support the concept of variants. Variants allow you to modify how the action will be executed based on the contexts available.
Let's assume you want to run a command that is different on macOS, Linux, and Windows.
1
actions:
2
# This action has a "default" execution for when the variants don't overlay,
3
# as it does not provide its own "where"
4
- action: command.run
5
command: echo
6
args:
7
- hello, world!
8
variants:
9
- where: os.name == "linux"
10
command: reboot
11
- where: os.name == "macos"
12
command: echo
13
args: ["Hello", "macOS"]
14
- where: user.username == "rawkode"
15
command: echo
16
args: ["Hello", "rawkode!"]
Copied!
We even allow you to target the Linux family and specific distribution:
1
actions:
2
- action: command.run
3
command: echo
4
args:
5
- hello, vanilla Linux!
6
variants:
7
- where: os.family == "Debian"
8
command: echo Hi, Debian
9
- where: os.distribution == "Ubuntu"
10
command: echo Hi, Ubuntu
11
- where: os.bitness == "64-bit"
12
command: echo Hi, 64 bit!
Copied!
Lastly, the where clause can be used to selectively skip or run tasks:
1
actions:
2
- action: command.run
3
where: os.name == "linux"
4
command: echo
5
args:
6
- Hello Linux
Copied!
Copy link