PyAction comes with a run
command that’s available when the pyaction[cli]
is installed. Consider the following main.py
file.
...
@workflow.action
def my_action(name: str, home_town: str) -> None:
workflow.write(
WorkflowContext(
{
"result": f"{name} lives in {home_town}!",
"phrase": f"{name} is also a Software Developer.",
},
)
)
This action takes two input parameters (name
and home_town
). To run this action, first add these input parameters to the .env
file.
INPUT_NAME=John
INPUT_HOME_TOWN=Chicago
Note that all the input keys in the .env
file should start with “INPUT_” and be written in uppercase.
Then, execute the run
command and see the result.
pyaction run
[
{
"var": "result",
"value": "John lives in Chicago!",
"type": "<class 'str'>",
"usage": "${{ steps.STEP_ID.outputs.result }}"
},
{
"var": "phrase",
"value": "John is also a Software Developer.",
"type": "<class 'str'>",
"usage": "${{ steps.STEP_ID.outputs.phrase }}"
}
]
The action runs, and the output is the variables available in the workflow.