feature: Trigger another action after first action completes
This commit is contained in:
parent
866a38f286
commit
29b6d12454
12
config.yaml
12
config.yaml
|
|
@ -154,21 +154,23 @@ actions:
|
|||
icon: box
|
||||
shell: docker start {{ container.Names }}
|
||||
entity: container
|
||||
trigger: Update container entity file
|
||||
|
||||
- title: Stop {{ container.Names }}
|
||||
icon: box
|
||||
shell: docker stop {{ container.Names }}
|
||||
entity: container
|
||||
trigger: Update container entity file
|
||||
|
||||
# Lastly, you can hide actions from the web UI, this is useful for creating
|
||||
# background helpers that execute only on startup or a cron, for updating
|
||||
# entity files.
|
||||
|
||||
# - title: Update container entity file
|
||||
# shell: 'docker ps -a --format json > /etc/OliveTin/containers.json'
|
||||
# hidden: true
|
||||
# execOnStartup: true
|
||||
# execOnCron: '*/1 * * * *'
|
||||
- title: Update container entity file
|
||||
shell: 'docker ps -a --format json > /etc/OliveTin/entities/containers.json'
|
||||
hidden: true
|
||||
execOnStartup: true
|
||||
execOnCron: '*/1 * * * *'
|
||||
|
||||
# An entity is something that exists - a "thing", like a VM, or a Container
|
||||
# is an entity. OliveTin allows you to then dynamically generate actions based
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ type Action struct {
|
|||
ExecOnCron []string
|
||||
ExecOnFileCreatedInDir []string
|
||||
ExecOnFileChangedInDir []string
|
||||
Trigger string
|
||||
MaxConcurrent int
|
||||
Arguments []ActionArgument
|
||||
PopupOnStart string
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ func DefaultExecutor() *Executor {
|
|||
stepExec,
|
||||
stepExecAfter,
|
||||
stepLogFinish,
|
||||
stepTrigger,
|
||||
}
|
||||
|
||||
return &e
|
||||
|
|
@ -357,3 +358,19 @@ func stepExecAfter(req *ExecutionRequest) bool {
|
|||
|
||||
return true
|
||||
}
|
||||
|
||||
func stepTrigger(req *ExecutionRequest) bool {
|
||||
if req.Action.Trigger != "" {
|
||||
trigger := &ExecutionRequest{
|
||||
ActionTitle: req.Action.Trigger,
|
||||
TrackingID: uuid.NewString(),
|
||||
Tags: []string{"trigger"},
|
||||
AuthenticatedUser: req.AuthenticatedUser,
|
||||
Cfg: req.Cfg,
|
||||
}
|
||||
|
||||
req.executor.ExecRequest(trigger)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue