Quick answer

Every GitHub Actions workflow must define when it runs using the top-level 'on' key.

GitHub Actions Missing 'on'

Every GitHub Actions workflow must define when it runs using the top-level 'on' key. Without it, the workflow is invalid.

Common causes

How to fix

GitHub Actions Missing “on” means your workflow file does not define any trigger events, so GitHub cannot determine when the automation should run. In GitHub Actions, the top-level on key is required for most workflows because it tells the runner whether to start on events like push, pull_request, workflow_dispatch, or a schedule. This validator helps developers, DevOps teams, and CI/CD maintainers quickly identify a common YAML configuration error before it blocks builds, deployments, or test automation.

How This Validator Works

This checker looks for the top-level on field in a GitHub Actions workflow definition and verifies that at least one valid trigger event is present. In a standard workflow YAML file, on is the event map that connects the workflow to GitHub activity. If the key is missing, empty, or malformed, the workflow may fail validation or never run as expected.

Common Validation Errors

Missing on is usually a structural problem in the workflow file rather than a runtime problem. It often happens when a workflow is copied from a template, partially edited, or generated automatically without a complete event definition.

Where This Validator Is Commonly Used

This validation is commonly used anywhere GitHub Actions workflows are created, reviewed, or automated. It is especially useful in teams that rely on CI/CD pipelines and want to prevent broken workflow files from reaching production branches.

Why Validation Matters

Validation helps ensure that workflow files are both syntactically correct and operationally meaningful. In GitHub Actions, a workflow without a trigger definition may be valid YAML in a general sense, but it is incomplete as an automation rule. Checking for on early reduces failed runs, confusing repository behavior, and time spent debugging pipeline configuration.

For teams managing multiple repositories, consistent workflow validation also improves maintainability. It makes automation easier to review, safer to update, and more predictable across environments.

Technical Details

GitHub Actions workflow files are typically written in YAML and stored under .github/workflows/. The on key is a top-level workflow property that defines event-based triggers. Depending on the workflow, it may be a single event or a list/map of events.

File format YAML
Required concept Top-level trigger declaration
Common events push, pull_request, workflow_dispatch, schedule
Typical location .github/workflows/*.yml or *.yaml
Related syntax concerns Indentation, mapping structure, event names, quoting behavior

In some YAML parsers, the word on can be treated carefully because of YAML parsing rules and schema differences. GitHub Actions handles it as a workflow trigger key, so the file must be structured in the format GitHub expects.

FAQ

What does “missing on” mean in GitHub Actions?

It means the workflow file does not define the top-level on trigger section. Without that section, GitHub does not know when the workflow should run. This is usually a configuration or YAML structure issue, not a problem with the repository itself.

Is the workflow invalid if it has no on key?

For GitHub Actions, yes, it is incomplete as a workflow definition. The file may still be valid YAML, but it does not function as a runnable automation workflow until a trigger event is added under on.

What are common trigger events for GitHub Actions?

Common triggers include push, pull_request, workflow_dispatch, schedule, and repository events such as releases or tags. The best trigger depends on whether the workflow is for testing, deployment, manual execution, or scheduled automation.

Can a workflow run without on?

No workflow can run automatically without a trigger definition. GitHub Actions needs the on key to know which event should start the job. If you want manual execution, workflow_dispatch is a common trigger to include.

Why does YAML indentation matter here?

YAML is indentation-sensitive. If on is placed at the wrong level, GitHub may not interpret it as a top-level trigger. Even a small spacing mistake can cause the workflow to behave incorrectly or fail validation.

Is on required for every GitHub Actions file?

For a standard workflow file, yes, a trigger definition is expected. Some reusable workflow patterns and advanced configurations may differ in structure, but most workflow files still need a clear event or invocation mechanism.

What is the difference between push and pull_request triggers?

push runs when code is pushed to a branch or tag, while pull_request runs when a pull request is opened, updated, or synchronized. Many teams use both so they can test changes before merge and also validate direct branch updates.

How do I fix a missing on error?

Add a top-level on block to the workflow file and define at least one valid event. For example, you can use on: push or a mapping such as on: [push, pull_request]. Then re-check the YAML structure and indentation.

Can this issue be caused by quoting or formatting?

Yes. While GitHub Actions often accepts several YAML styles, formatting mistakes can still break parsing. Incorrect quoting, nested keys, or malformed lists may prevent the trigger block from being recognized as intended.

Related Validators & Checkers

FAQ

What events can I use in GitHub Actions 'on'?
Common events: push, pull_request, workflow_dispatch, schedule, repository_dispatch. See GitHub docs for the full list.

Fix it now

Try in validator (prefill this example)

Related

All tools · Canonical