Skip to content

Inputs

Bases: EnvAttrDictVars

GitHub Action input variables.

Usage:

class MyInputs(ActionInputs):
    my_input: str

action = ActionBase(inputs=MyInputs())
print(action.inputs.my_input)
print(action.inputs["my-input"])  # the same as above

With attributes, you can only access explicitly declared vars, with dict-like access you can access any var. This way you can find your balance between strictly defined vars and flexibility.

Attribute names are converted to kebab-case. So action.inputs.my_input is the same as action.inputs["my-input"].

If you need to access a snake_case named input my_input, you should use dict-style only: action.inputs["my_input"]. But it's common to use kebab-case in GitHub Actions input names.

By GitHub convention, all input names are upper-cased in the environment and prefixed with "INPUT_". So actions.inputs.my_input or actions.inputs['my-input'] will be the variable INPUT_MY-INPUT in the environment. The ActionInputs does the conversion automatically.

Uses lazy loading of the values. So the value is read from the environment only when accessed and only once, and saved in the object's internal dict.