Trigger
A CI/CD trigger is the event that starts a pipeline run, such as a push, pull request, tag, schedule, manual dispatch, or webhook.
Understanding CI/CD Triggers
What Is a Trigger and Which Types Matter
A trigger tells a pipeline when to run and with what context. Different events should start different pipelines: a feature branch push runs tests, a merge to main deploys to staging, and a version tag deploys to production. Getting this right avoids wasted minutes and accidental deploys.
| Trigger | Typical use |
|---|---|
| push | Run CI on new commits |
| pull_request | Validate before merge, no deploy |
| tag | Release to production |
| schedule | Nightly scans, drift checks |
| workflow_dispatch | Manual run with inputs |
| webhook | External systems such as alerts |
Complete Trigger Configuration
Each event key may appear only once in a workflow, so branches and tags for push go under the same key.
on: push: branches: - main - 'release/**' tags: - 'v*.*.*' paths: - 'src/**' - 'Dockerfile' - '.github/workflows/**' pull_request: branches: [main] types: [opened, synchronize, reopened] schedule: - cron: '30 20 * * *' # 20:30 UTC is 02:00 IST the next day workflow_dispatch: inputs: environment: description: Target environment required: true default: staging type: choice options: [staging, production]When both branches and tags are listed under push, the workflow runs for pushes that match either filter. Path filters apply to branch pushes and do not apply to tag pushes.
GitLab CI Trigger Rules
deploy-production: stage: deploy script: - ./deploy.sh production rules: - if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/ when: manual - when: neverPractical Commands
# Manual run with inputsgh workflow run deploy.yaml --field environment=staging # Trigger through the APIcurl -X POST \ -H "Authorization: Bearer $GITHUB_TOKEN" \ https://api.github.com/repos/zerodha/kite-api/actions/workflows/deploy.yaml/dispatches \ -d '{"ref":"main","inputs":{"environment":"staging"}}' # Create a tag to start a release pipelinegit tag -a v1.2.3 -m "Release v1.2.3"git push origin v1.2.3Troubleshooting
| Symptom | Check | What to look for |
|---|---|---|
| Not triggering on push | Branch and path filters | Exact name or path match |
| Trigger loop | Who creates commits | Pipeline commits retriggering itself |
| Schedule not running | Cron syntax and repo activity | Invalid cron or disabled schedule |
TipUse path filters so documentation-only changes skip the full pipeline, saving runner minutes and attention.
RememberOn GitHub, scheduled workflows in public repositories are disabled after 60 days without repository activity. Re-enable them if a nightly job silently stops.
SecurityBe careful with
pull_request_target. It runs with access to secrets even for fork pull requests. Usepull_requestfor untrusted code.
Common MistakeRunning the full deploy pipeline on every push to every branch. Scope deploy jobs to main or tags and protect main so deploys follow deliberate merges.
Frequently Asked Questions
Besides a push, which triggers matter most in production pipelines?
Pull request triggers validate changes before merge, schedules run nightly scans or drift checks, manual dispatch gates sensitive deploys behind a human, and webhooks let external systems start pipelines.
Why did my pipeline trigger itself in a loop?
A job probably commits or tags something that matches its own trigger. Skip runs for bot commits, use a skip marker in the commit message, or filter by branch or path.
How do I run a pipeline only for releases?
Trigger on version tags such as v1.2.3 and gate the deploy job on that tag pattern, optionally behind a manual approval. ===