run-action
The Declarative Hook of type run-action allows you to run Actions from a Stack when a Plugin is applied in an Application or Infrastructure.
schema-version: v4
kind: plugin
metadata:
name: run-action-hook-plugin
display-name: run-action-hook-plugin
description: Describe what your Plugin does.
version: 0.0.1
spec:
type: app
compatibility:
- python
docs:
pt-br: docs/pt-br/docs.md
en-us: docs/en-us/docs.md
single-use: false
requires:
actions:
- my-studio-slug/my-stack-slug@1.0.0/my-action-slug
technologies: # Ref: https://docs.stackspot.com/create-use/create-content/yaml-files/plugin-yaml/#technologies-1
- Api
stk-projects-only: false
inputs:
- label: Select the connection for your my-dynamo-conn
name: my-dynamo-conn
type: required-connection
connection-interface-type: aws-dynamo-conn
- label: Type the name of your resource
name: resource
type: text
required: true
hooks:
- type: run-action
trigger: after-render
name: my-studio-slug/my-stack-slug@1.0.0/my-action-slug
inputs:
user_name: User with {{ resource }}
env: qastaging
connections:
- alias: my-dynamo-conn
selected: aws-dynamo-conn-selected
Available fields in the run-action Declarative Hook
trigger:
Field to define when the Declarative Hook must be executed.
before-input
Executes the Declarative Hook before receiving the input parameters from the user.
trigger: before-input
before-render
Executes the Declarative Hook before the Template generates files in the project.
trigger: before-render
after-render
Executes the Declarative Hook after the Template generates files in the project.
trigger: after-render
name:
The name of the Action you want to execute.
You can use one of the following syntaxes:
- Without specifying the Stack version (the latest published Stack version will be used):
<studio-slug>/<stack-slug>/<action-slug>
- With a specific Stack version:
<studio-slug>/<stack-slug>@<stack-version>/<action-slug>
Example:
name: my-studio-slug/my-stack-slug@1.0.0/my-action-slug
-
If you omit the semantic version and use only
<studio-slug>/<stack-slug>/<action-slug>, therun-actionDeclarative Hook executes the Action from the latest published version of the Stack. -
All Actions used in the
run-actionDeclarative Hook must be listed in therequires.actionsfield from your Plugin.
inputs: (Optional)
If the Action has inputs, you need to put them in the run-action Declarative Hook.
For each input, fill in the Declarative Hook as follows:
input_name: input value
Example:
The following Action example has an input named user_name. In the run-action in a Plugin example tab, you can see the same input filled in the run-action Declarative Hook snippet:
- Action example
- run-action in a Plugin example
schema-version: v3
kind: action
metadata:
name: my-python-action
display-name: my-python-action
spec:
type: python
docs:
pt-br: docs/pt-br/docs.md
en-us: docs/en-us/docs.md
requires:
actions:
- my-studio/my-stack@1.0.0/my-python-action
inputs:
- label: Who are you?
name: user_name
type: text
required: false
pattern: '([A-Z][a-z]+)+'
help: 'Inform your name'
python:
workdir: .
script: script.py
# ***Other Plugin fields above!***
hooks:
- type: run-action
trigger: after-render
name: my-studio/my-stack@1.0.0/my-python-action
inputs:
user_name: User with {{ resource }}
The inputs: field supports Jinja data manipulation and filters.
env: (Optional)
Inform a specific environment where the Action will run.
Example:
# ***Other Plugin fields above!***
hooks:
- type: run-action
trigger: after-render
name: my-studio/my-stack@1.0.0/my-action-slug
inputs:
user_name: User with {{ resource }}
env: qastaging
connections: (Optional)
If your Action requires Connections, inform the Connection alias and selected type as follows:
Example:
- Action with input required-connection example
- run-action with Connections
schema-version: v3
kind: action
metadata:
name: my-python-action
display-name: my-python-action
description: Describe your action explaining its purpose
spec:
type: python
docs:
pt-br: docs/pt-br/docs.md
en-us: docs/en-us/docs.md
requires:
actions:
- my-studio-slug/my-stack-slug@1.0.0/my-action-slug
inputs:
- label: Select the connection for your my-dynamo-conn
name: my-dynamo-conn
type: required-connection
connection-interface-type: aws-dynamo-conn
- label: Who are you?
name: user_name
type: text
required: false
pattern: '([A-Z][a-z]+)+'
help: 'Inform your name'
python:
workdir: .
script: script.py
# ***Other Plugin fields above!***
hooks:
- type: run-action
trigger: after-render
name: my-studio/my-stack@1.0.0/my-action-slug
inputs:
user_name: User with {{ resource }}
env: qastaging
connections:
- alias: my-dynamo-conn
selected: aws-dynamo-conn