Create Actions
Create an Action
You can create Actions via the STK CLI. By default, every Action has a local scope, and you can only execute via STK CLI. You can also configure the Action in your Account and execute it remotely.
To create the initial structure of your Action, execute the [stk create action] command (home/stk-cli/commands/action-commands.md#stk-create-action). Check the example below:
stk create action my-action-name
After running the above command, answer a few questions in the terminal:
- Choose the Action type:
- python
- shell
You can inform the type of Action through the terminal with the option --type
.
-
Add a URL to a Git repository to host your Action's code to be displayed on the StackSpot Platform. Or use the
--remote
option in the terminal. -
Define the initial version of your Action in the format
X.Y.Z
(only numbers, example:1.1.0
), or use the--version
option in the terminal. -
Add a description for the Action, or use the option
--description
. Enter the text between double quotes (" Text description "
) in the terminal. Here, add why you are creating this Action.
stk create action my-action-name --type container --remote https://github.com/my-action-name/repo --version 1.1.0 --description "The purpose of my Action"
Validate and Publish an Action in a Studio
After creating your Action, you can test it by running it before publishing it.
Before publishing your Action, you need to validate its structure. Follow the steps:
To publish an Action, check if the Slug (Identifier) is unique in the Studio. Having more than one Slug with the same ID (either Stack, Plugin, or Action) in a Studio is impossible.
Step 1. Execute the stk validate action command inside the Action's folder.
stk run validate action
Step 2. If the validation was successful, follow the instructions below to publish your Action.
If it returns any errors, you must fix them and rerun the validation.
- In your Action folder, execute the stk publish action command:
stk publish action --studio [studio-name]
- Inform which Studio you want to publish the Action using the
--studio
option.
Example:
stk publish action --studio my-studio-name
Execute an Action
You execute an Action locally on your machine. See the following:
Run unpublished Action
You can run Actions locally if you haven’t published. To test Action's function, execute the command informing the path of the Action folder:
Run the stk run action command.
Example:
stk run action /Users/user.name/my-action-name
Run published Action
Published Actions are available on the StackSpot Platform. You can execute the published Actions using the predefined information in your Account's Workspace or not.
You can run the Action using the Workspace or not. Check the examples below:
1. Execute an Action without using Workspace context variables
Follow the pattern <studio-slug>/<action-name>@<action-version>
. It can only be used when there is no active Workspace.
Example without Workspace:
stk run action my-studio-name/action-name@1.0.0
2. Run an Action using the context variables configured for the Action on the Stack in an active Workspace
The Action version (@stack-version
) can only be set if there is no active Workspace: <studio-slug>/<stack-slug>/<action-name>@<stack-version>
.
Example with active Workspace:
stk run action my-studio-name/my-stack-name/my-action-name
Ensure your Team still belongs to the Studio to which you added your Action. If you delete a team from the Studio, you won't be able to perform any actions on it.