Developing Pipeline Trigger Rules
This lesson explains the trigger types on each platform, and how to design rules for a monorepo.
Learning outcomes
After completing this lesson, you will be able to:
- Configure CI, pull request and scheduled triggers.
- Explain why Azure Repos needs build validation.
- Choose a GitHub Actions event.
- Apply path filters safely.
Trigger types in Azure Pipelines
CI triggers
The trigger keyword runs a pipeline when commits reach matching branches. With no trigger section, a YAML pipeline runs for a push to any branch, which often surprises new users. trigger: none disables CI. Branch, path and tag filters narrow the rule, and batch: true combines commits that arrive during a run into one later run.
trigger:
batch: true
branches:
include:
- main
- release/*
exclude:
- release/old-*
paths:
include:
- src/*
exclude:
- docs/*Pull request triggers
The pr keyword applies to GitHub and Bitbucket Cloud. Azure Repos ignores it, so pull request runs for Azure Repos come from a build validation branch policy.
Scheduled triggers
schedules use cron syntax, and times are in UTC. always: true runs even if nothing has changed. Without that setting, a schedule runs only if there are new changes since the last successful scheduled run.
schedules:
- cron: '0 2 * * 1-5'
displayName: Weeknight build
branches:
include:
- main
always: falsePipeline and resource triggers
A pipeline resource starts one pipeline when another completes, which is useful for splitting CI and CD, and repository, container and package resources can also trigger runs. A webhook resource accepts external events.
resources:
pipelines:
- pipeline: build
source: web-ci
trigger:
branches:
include:
- mainAzure Pipelines triggers
Events in GitHub Actions
GitHub Actions uses the on key, with many possible events. The following example combines several of them.
on:
push:
branches: [main, 'release/**']
paths-ignore: ['docs/**', '**.md']
tags: ['v*']
pull_request:
branches: [main]
types: [opened, synchronize, reopened]
schedule:
- cron: '30 5 * * 1'
workflow_dispatch:
inputs:
environment:
description: Target environment
type: choice
options: [test, staging]
workflow_run:
workflows: [build]
types: [completed]The events differ in important ways. push runs on commits. pull_request runs on the merge result of a pull request, and from forks it receives no secrets. schedule runs on the default branch, in UTC, and it may be delayed at busy times. workflow_dispatch adds a manual Run button with optional inputs. workflow_run runs after another workflow, and repository_dispatch lets an external system start a run. workflow_call marks a workflow as reusable. merge_group runs checks for a merge queue.
A commit message containing [skip ci] skips push and pull request runs on GitHub Actions, and [skip ci] or ***NO_CI*** likewise skips CI on Azure Pipelines. This is commonly used to stop a pipeline's own commits from starting another run.
GitHub Actions events
Designing rules for a monorepo
A single repository holding several services needs path filters, so that a change to one service does not build all of them. One practical warning applies: when a path filter stops a pipeline from running, a required check for that pipeline may stay unresolved. In Azure Repos, a build validation policy with a matching path filter avoids this. In GitHub, a job that always runs and evaluates which paths changed, using a step such as dorny/paths-filter, can report a result to the required check.
The following table recaps how a requirement maps to a rule.
| Requirement | Azure Pipelines | GitHub Actions |
|---|---|---|
| Build each push to main | trigger with branches | on: push with branches |
| Build on a pull request | Build validation (Azure Repos) or pr (GitHub) | on: pull_request |
| Nightly run | schedules | on: schedule |
| Manual run with inputs | Runtime parameters | on: workflow_dispatch |
| Run after another pipeline | Pipeline resource trigger | on: workflow_run |
| Reduce runs on busy branches | batch: true | concurrency with cancel-in-progress |
The following diagram compares the pr: keyword with a build validation policy for starting a pipeline from pull requests in Azure Repos.

The same rule on both platforms
A trigger that does not fire
An Azure Repos team adds a pr: section to its YAML file, naming main. Pull requests to main do not start the pipeline. What should the team do?
The team should add a build validation policy on main that references the pipeline, since Azure Repos does not use the pr keyword. Changing the branch filter syntax would make no difference, and adding a CI trigger would run after the merge rather than for the pull request.
Without always: true, when does an Azure Pipelines schedule skip a run?
Show answer
When there are no new changes since the last successful scheduled run.
Exam Tips
Remember for the exam
- With no trigger section, a YAML pipeline runs on all branches.
- Azure Repos ignores pr; use a build validation policy.
- Schedules are in UTC, and do not run without changes unless always: true is set.
- workflow_dispatch adds a manual run with inputs.
- A pull_request run from a fork receives no secrets.