Github variables
In the vars
attribute of the action class, you can access all the environment variables provided by GitHub.
The library provides a full list of GitHub environment variables, including descriptions.
Paths and files have type Path.
from github_custom_actions import ActionBase
class MyAction(ActionBase):
def main(self):
self.outputs["runner-os"] = self.env.runner_os
self.summary.text += (
self.render(
"### {{ inputs['my-input'] }}.\n"
"Have a nice day!"
)
)
if __name__ == "__main__":
MyAction().run()
IDE autocomplete and hover documentation are supported: .
If accessed through a dictionary, the variable name remains unchanged; if accessed through class attributes, the
attribute name is converted to uppercase.
So action.env["GITHUB_REPOSITORY"]
and action.env.github_repository
refer to the same variable.
This way with dictionary-like syntax you can access to any environment variable, not only set by Github.
For implementation details, see GithubVars.