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 - ComputeRequirements for .github/actions/ComputeRequirements/action.yml -, because a step names it that way in uses. The name key is DisplayName.

  • Using is how the action runs - runs.using, as composite, docker or node24:

    • Of a composite action (IsComposite), the Steps are read, so IterateActions() yields the actions it runs in turn.

    • Of a Docker action, the Image it runs - Dockerfile or docker://alpine:3.22.

  • A step of an action is a Step, as a step of a job is - with its name, id, if, and the action in uses or the script in run.

  • An action’s inputs and outputs aren’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 .github directory 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 same Action.

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.