repomatic.metadata.env moduleΒΆ
GitHub Actions environment accessors of Metadata.
Every property here reads the workflow-run environment (the event payload,
the GITHUB_* variables) and nothing else: no git, no pyproject.toml.
- class repomatic.metadata.env.EnvironmentMetadata[source]ΒΆ
Bases:
objectWorkflow-run environment: the event payload and
GITHUB_*variables.A concern mixin of
Metadata: never instantiated on its own.- property github_event: dict[str, Any][source]ΒΆ
Load the GitHub event payload from
GITHUB_EVENT_PATH.GitHub Actions sets
GITHUB_EVENT_PATHto a JSON file holding the complete webhook event payload.Delegates to
repomatic.github.event.get_github_event(), the one loader of the payload, which reads a missing file as an empty payload. Only the warning about a CI run missing the variable lives here, since the shared loader serves callers outside CI too.
- property event_type: WorkflowEvent | None[source]ΒΆ
Returns the type of event that triggered the workflow run.
Maps
event_name(theGITHUB_EVENT_NAMEvariable, set by GitHub Actions on every run) onto itsWorkflowEventmember, soscheduleandworkflow_dispatchruns resolve to their own event instead of falling in aNonehole that nulls every commit matrix.- Returns:
The event, or
Noneoutside CI, or whenGITHUB_EVENT_NAMEis absent or names an event this project does not know. Each case is logged as a warning.
- property event_actor: str | None[source]ΒΆ
Returns the GitHub login of the user that triggered the workflow run.
- property event_sender_type: str | None[source]ΒΆ
Returns the type of the user that triggered the workflow run.
- property is_bot: bool[source]ΒΆ
Returns
Trueif the workflow was triggered by a bot or automated process.This is useful to only run some jobs on human-triggered events. Or skip jobs triggered by bots to avoid infinite loops.
The sender type covers every GitHub App, which is how Dependabot and Renovate author their pull requests. The Dependabot login is a second signal for downstream repositories:
sender.typeis absent from the event payload outsidepushandpull_request(and empty when the payload cannot be read at all), and the login is then the only thing left to match on.The test is deliberately not
sender.type != "User", which would also classify anOrganizationsender as a bot.
- property head_branch: str | None[source]ΒΆ
Returns the head branch name for pull request events.
For pull request events, this is the source branch name (e.g.,
update-mailmap). For push events, returnsNonesince thereβs no head branch concept.The branch name is extracted from the
GITHUB_HEAD_REFenvironment variable, which is only set for pull request events.
- property event_name: str | None[source]ΒΆ
Returns the name of the event that triggered the workflow.
Reads
GITHUB_EVENT_NAME. This is the raw event name ("push","pull_request","workflow_run"), whichevent_typeresolves to aWorkflowEventmember.
- property job_name: str | None[source]ΒΆ
Returns the ID of the current job in the workflow.
Reads
GITHUB_JOB.
- property ref: str | None[source]ΒΆ
Returns the full ref that triggered the workflow, like
refs/heads/main.Reads
GITHUB_REF.
- property ref_name: str | None[source]ΒΆ
Returns the short ref name of the branch or tag.
Reads
GITHUB_REF_NAME.
- property repo_name: str | None[source]ΒΆ
Returns the repository name without owner prefix.
Derived from
repo_slug.
- property is_awesome: bool[source]ΒΆ
Whether this is an awesome-list repository.
Detected by the
awesome-prefix on the repository name.
- property repo_owner: str | None[source]ΒΆ
Returns the repository owner.
Reads
GITHUB_REPOSITORY_OWNER, falling back to the owner component ofrepo_slug.
- property repo_slug: str | None[source]ΒΆ
Returns the
owner/nameslug for the current repository.Resolution order: the
GITHUB_REPOSITORYvariable (CI), the URL of theoriginremote (offline), thengh repo view. The remote comes beforeghbecause reading it costs no network call, and noghdownload on a machine that lacks one.
- property repo_url: str | None[source]ΒΆ
Returns the full URL to the repository.
Derived from
server_urlandrepo_slug.
- property run_attempt: str | None[source]ΒΆ
Returns the run attempt number.
Reads
GITHUB_RUN_ATTEMPT.
- property run_id: str | None[source]ΒΆ
Returns the unique ID of the current workflow run.
Reads
GITHUB_RUN_ID.
- property run_number: str | None[source]ΒΆ
Returns the run number for the current workflow.
Reads
GITHUB_RUN_NUMBER.
- property server_url: str[source]ΒΆ
Returns the GitHub server URL.
Reads
GITHUB_SERVER_URL, defaulting tohttps://github.com.
- property sha: str | None[source]ΒΆ
Returns the commit SHA that triggered the workflow.
Reads
GITHUB_SHA.
- property triggering_actor: str | None[source]ΒΆ
Returns the login of the user that initiated the workflow run.
Reads
GITHUB_TRIGGERING_ACTOR. This differs fromevent_actor(GITHUB_ACTOR) when a workflow is re-run by a different user.