PyAction helps you to develop GitHub Actions using Python. It's delivered as an installable package with the ability to test the action locally before any deployment.
from pyaction import PyAction
workflow = PyAction.workflow()
@workflow.action()
def greetings_action(name: str, age: int) -> None:
workflow.write(
{
"phrase": f"Hello {name}. You are {age}!"
}
)
# $ pyaction run
# ┏━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
# ┃ Variable ┃ Value ┃ Type ┃ Workflow Usage ┃
# ┡━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
# │ phrase │ Hello Jane. You are 20! │ <class 'str'> │ ${{ steps.STEP_ID.outputs.phrase }} │
# └──────────┴─────────────────────────┴───────────────┴─────────────────────────────────────┘
Check out the official docs for more detailed information. There is also a Quickstart demo tutorial that walks you through a simple hello-world action.
Run the following command in a fresh CLI tab.
pip install -U "pyaction[cli]"
flowchart TB
subgraph GitHub Runner
pyaction-->pydantic;
pyaction-->pygithub;
end
pc[pyaction-cli]-->pyaction;
pc[pyaction-cli]-->rich;
pc[pyaction-cli]-->copier;
pc[pyaction-cli]-->_[click];
To make sure the installation process was successful, run the following command.
pyaction --version
It's recommended to initialize a template, then going along the development process. Thus, run the init
command.
pyaction init
Answer the prompts and your template will be generated. Check out the docs for the further steps.
All your contributions and assistance are welcome. For more information about how you can contribute to the project, please follow the instructions here. ✨
PyAction is licensed under the MIT License terms.