Action File
pyTooling.GitHub.WorkflowFile models a GitHub Actions action file too - the action.yml a step runs
with uses:
from pathlib import Path
from pyTooling.GitHub.WorkflowFile import Action
action = Action.FromFile(Path(".github/actions/CheckArtifactNames/action.yml"))
print(f"{action.Name} ({action.Using}): {action.StepCount} steps")
for step in action.IterateSteps():
print(f" {step.Location:<16} {step.Name}")
CheckArtifactNames (composite): 2 steps
action.yml:21 Install dependencies
action.yml:25 Check artifact names
The Tree
Action an action's file, 'action.yml'
+-- Step a step of a composite action
+-- UsesReference the action the step runs
An action is named by its directory -
ComputeRequirementsfor.github/actions/ComputeRequirements/action.yml-, because a step names it that way inuses. Thenamekey isDisplayName.Usingis how the action runs -runs.using, ascomposite,dockerornode24:Of a composite action (
IsComposite), theStepsare read, soIterateActions()yields the actions it runs in turn.Of a Docker action, the
Imageit runs -Dockerfileordocker://alpine:3.22.
A step of an action is a
Step, as a step of a job is - with itsname,id,if, and the action inusesor the script inrun.An action’s
inputsandoutputsaren’t read.
An action is the root of its file’s elements: assigning it a parent raises a TypeError. Every element knows the
line it starts at, and a file that isn’t a well-formed action - no runs key, or no runs.using - raises
WorkflowError, naming the file and the line.
Actions a Step Runs
ResolveAction() reads the action a step runs from its
action.yml, as Resolve() reads a called workflow (see
Called Workflows), so the actions a composite action runs in turn are known:
An action of a mapped repository -
pyTooling/Actions/.github/actions/ComputeRequirements@r8- is read from the repository’s root, the directory holding the.githubdirectory the mapped directory is in.A local action -
./.github/actions/ComputeRequirements- is read from the root of the repository of the calling workflow or action.LoadAction()reads an action’s file by its path. Every file is read once; reading it again returns the sameAction.
The gha domain’s Dependencies lists a composite action with the actions its steps run, and a Docker
action with its image, as read this way.