Skip to content

Triggers

The trigger models define the on: section of a workflow, controlling when the workflow runs. The top-level On class contains fields for each event type.

The top-level trigger configuration. Common event types have typed fields; less common events can use the extras parameter.

from ghagen.models.trigger import On, PushTrigger, PRTrigger
on = On(
push=PushTrigger(branches=["main"]),
pull_request=PRTrigger(branches=["main"]),
)
ParameterTypeDefaultDescription
pushPushTrigger | NoneNonePush event configuration.
pull_requestPRTrigger | NoneNonePull request event configuration.
pull_request_targetPRTrigger | NoneNonePull request target event configuration.
workflow_dispatchWorkflowDispatchTrigger | bool | NoneNoneManual dispatch trigger. Set to True or WorkflowDispatchTrigger() for no inputs.
workflow_callWorkflowCallTrigger | NoneNoneReusable workflow call trigger.
workflow_rundict[str, Any] | NoneNoneWorkflow run event configuration.
schedulelist[ScheduleTrigger] | NoneNoneCron schedule triggers.
releasedict[str, Any] | NoneNoneRelease event configuration.
issuesdict[str, Any] | NoneNoneIssues event configuration.
issue_commentdict[str, Any] | NoneNoneIssue comment event configuration.
createdict[str, Any] | NoneNoneBranch/tag creation event.
deletedict[str, Any] | NoneNoneBranch/tag deletion event.
forkdict[str, Any] | NoneNoneFork event configuration.
page_builddict[str, Any] | NoneNoneGitHub Pages build event.
deploymentdict[str, Any] | NoneNoneDeployment event configuration.
deployment_statusdict[str, Any] | NoneNoneDeployment status event.
check_rundict[str, Any] | NoneNoneCheck run event configuration.
check_suitedict[str, Any] | NoneNoneCheck suite event configuration.
labeldict[str, Any] | NoneNoneLabel event configuration.
milestonedict[str, Any] | NoneNoneMilestone event configuration.
projectdict[str, Any] | NoneNoneProject event configuration.
project_carddict[str, Any] | NoneNoneProject card event configuration.
project_columndict[str, Any] | NoneNoneProject column event configuration.
publicdict[str, Any] | NoneNoneRepository visibility change event.
registry_packagedict[str, Any] | NoneNoneRegistry package event.
statusdict[str, Any] | NoneNoneCommit status event.
watchdict[str, Any] | NoneNoneWatch/star event configuration.

Events without a dedicated model accept a dict[str, Any] for full flexibility.

Configuration for push event triggers. Filters which pushes trigger the workflow.

from ghagen.models.trigger import PushTrigger
push = PushTrigger(
branches=["main", "release/*"],
paths=["src/**"],
paths_ignore=["docs/**"],
)
ParameterTypeDefaultDescription
brancheslist[str] | NoneNoneBranch filter patterns (supports glob).
branches_ignorelist[str] | NoneNoneBranch exclusion patterns. Serialized as branches-ignore.
tagslist[str] | NoneNoneTag filter patterns.
tags_ignorelist[str] | NoneNoneTag exclusion patterns. Serialized as tags-ignore.
pathslist[str] | NoneNonePath filter patterns. Only pushes affecting these paths trigger the workflow.
paths_ignorelist[str] | NoneNonePath exclusion patterns. Serialized as paths-ignore.

Configuration for pull_request and pull_request_target event triggers.

from ghagen.models.trigger import PRTrigger
pr = PRTrigger(
branches=["main"],
types=["opened", "synchronize"],
)
ParameterTypeDefaultDescription
brancheslist[str] | NoneNoneBranch filter patterns (matches the PR’s base branch).
branches_ignorelist[str] | NoneNoneBranch exclusion patterns. Serialized as branches-ignore.
pathslist[str] | NoneNonePath filter patterns.
paths_ignorelist[str] | NoneNonePath exclusion patterns. Serialized as paths-ignore.
typeslist[str] | NoneNoneActivity types to filter on (e.g., ["opened", "synchronize", "reopened"]).

Configuration for cron-based schedule triggers.

from ghagen.models.trigger import ScheduleTrigger
schedule = ScheduleTrigger(cron="0 0 * * 1") # Every Monday at midnight
ParameterTypeDefaultDescription
cronstrrequiredPOSIX cron expression (e.g., "0 0 * * *" for daily at midnight).

Configuration for workflow_dispatch (manual) triggers. Allows defining input parameters that users provide when triggering the workflow manually.

from ghagen.models.trigger import WorkflowDispatchTrigger, WorkflowDispatchInput
dispatch = WorkflowDispatchTrigger(
inputs={
"environment": WorkflowDispatchInput(
description="Deployment target",
required=True,
type="choice",
options=["staging", "production"],
),
},
)
ParameterTypeDefaultDescription
inputsdict[str, WorkflowDispatchInput] | NoneNoneInput parameter definitions, keyed by input name.

An input parameter for workflow_dispatch triggers.

ParameterTypeDefaultDescription
descriptionstr | NoneNoneHuman-readable description of the input.
requiredbool | NoneNoneWhether the input is required.
defaultstr | NoneNoneDefault value for the input.
typestr | Raw[str] | NoneNoneInput type (e.g., "string", "boolean", "choice", "environment").
optionslist[str] | NoneNoneAvailable options when type is "choice".

Configuration for workflow_call (reusable workflow) triggers. Defines the interface for a workflow that can be called by other workflows.

from ghagen.models.trigger import (
WorkflowCallTrigger,
WorkflowCallInput,
WorkflowCallOutput,
WorkflowCallSecret,
)
call = WorkflowCallTrigger(
inputs={
"environment": WorkflowCallInput(
description="Target environment",
required=True,
type="string",
),
},
outputs={
"deploy-url": WorkflowCallOutput(
description="Deployment URL",
value="${{ jobs.deploy.outputs.url }}",
),
},
secrets={
"DEPLOY_TOKEN": WorkflowCallSecret(
description="Deployment token",
required=True,
),
},
)
ParameterTypeDefaultDescription
inputsdict[str, WorkflowCallInput] | NoneNoneInput parameter definitions.
outputsdict[str, WorkflowCallOutput] | NoneNoneOutput definitions.
secretsdict[str, WorkflowCallSecret] | NoneNoneSecret definitions.

An input parameter for workflow_call triggers.

ParameterTypeDefaultDescription
descriptionstr | NoneNoneHuman-readable description of the input.
requiredbool | NoneNoneWhether the input is required.
defaultstr | NoneNoneDefault value.
typestr | Raw[str] | NoneNoneInput type ("string", "boolean", "number").

An output for workflow_call triggers.

ParameterTypeDefaultDescription
descriptionstr | NoneNoneHuman-readable description.
valuestrrequiredThe output value, typically referencing a job output expression.

A secret definition for workflow_call triggers.

ParameterTypeDefaultDescription
descriptionstr | NoneNoneHuman-readable description.
requiredbool | NoneNoneWhether the secret is required.