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
|
icon: box
|
||||||
shell: docker start {{ container.Names }}
|
shell: docker start {{ container.Names }}
|
||||||
entity: container
|
entity: container
|
||||||
|
trigger: Update container entity file
|
||||||
|
|
||||||
- title: Stop {{ container.Names }}
|
- title: Stop {{ container.Names }}
|
||||||
icon: box
|
icon: box
|
||||||
shell: docker stop {{ container.Names }}
|
shell: docker stop {{ container.Names }}
|
||||||
entity: container
|
entity: container
|
||||||
|
trigger: Update container entity file
|
||||||
|
|
||||||
# Lastly, you can hide actions from the web UI, this is useful for creating
|
# 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
|
# background helpers that execute only on startup or a cron, for updating
|
||||||
# entity files.
|
# entity files.
|
||||||
|
|
||||||
# - title: Update container entity file
|
- title: Update container entity file
|
||||||
# shell: 'docker ps -a --format json > /etc/OliveTin/containers.json'
|
shell: 'docker ps -a --format json > /etc/OliveTin/entities/containers.json'
|
||||||
# hidden: true
|
hidden: true
|
||||||
# execOnStartup: true
|
execOnStartup: true
|
||||||
# execOnCron: '*/1 * * * *'
|
execOnCron: '*/1 * * * *'
|
||||||
|
|
||||||
# An entity is something that exists - a "thing", like a VM, or a Container
|
# 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
|
# is an entity. OliveTin allows you to then dynamically generate actions based
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ type Action struct {
|
||||||
ExecOnCron []string
|
ExecOnCron []string
|
||||||
ExecOnFileCreatedInDir []string
|
ExecOnFileCreatedInDir []string
|
||||||
ExecOnFileChangedInDir []string
|
ExecOnFileChangedInDir []string
|
||||||
|
Trigger string
|
||||||
MaxConcurrent int
|
MaxConcurrent int
|
||||||
Arguments []ActionArgument
|
Arguments []ActionArgument
|
||||||
PopupOnStart string
|
PopupOnStart string
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,7 @@ func DefaultExecutor() *Executor {
|
||||||
stepExec,
|
stepExec,
|
||||||
stepExecAfter,
|
stepExecAfter,
|
||||||
stepLogFinish,
|
stepLogFinish,
|
||||||
|
stepTrigger,
|
||||||
}
|
}
|
||||||
|
|
||||||
return &e
|
return &e
|
||||||
|
|
@ -357,3 +358,19 @@ func stepExecAfter(req *ExecutionRequest) bool {
|
||||||
|
|
||||||
return true
|
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