Which YAML snippet triggers a GitHub Actions workflow for both push and pull_request events?
push
pull_request
A workflow subscribes to multiple events by listing each event name under the on key, and each event can carry its own branches filter. Declaring push with branches: [main] together with pull_request with branches: [main] runs the workflow on every push to main and on every pull request targeting main, covering both event types for the same branch. Listing only push never fires for pull requests, and because on is a YAML mapping, repeating the push key twice is invalid YAML rather than a way to subscribe to a second event.
on
branches
branches: [main]
main
Community Discussion