QuestionQ19

Author and manage workflows

Which YAML snippet triggers a GitHub Actions workflow for both push and pull_request events?

  • A
  • B
  • C
  • D
Explanation

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.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!