GH-200 · Question #2
As a developer, you need to add the correct syntax to allow the following workflow file to be triggered by multiple types of events. Which two code blocks should you add starting at line 5? (Each…
The correct answer is C. on. GitHub Actions supports two valid syntaxes for specifying multiple trigger events. The inline array syntax - 'on: [push, pull_request]' - is compact and fully valid. The YAML block mapping syntax uses 'on:' followed by indented event keys (e.g., push: and pull_request:) which…
Question
As a developer, you need to add the correct syntax to allow the following workflow file to be triggered by multiple types of events. Which two code blocks should you add starting at line 5? (Each correct answer presents a complete solution. Choose two.)
Exhibit
Options
- Aon: [push, pull_request]
- Bon:
- Con:
- Don: [push, commit]
- Eon:
- Fon:
How the community answered
(21 responses)- A5% (1)
- C90% (19)
- E5% (1)
Explanation
GitHub Actions supports two valid syntaxes for specifying multiple trigger events. The inline array syntax - 'on: [push, pull_request]' - is compact and fully valid. The YAML block mapping syntax uses 'on:' followed by indented event keys (e.g., push: and pull_request:) which allows adding filters like branches or paths per event. Option D ('on: [push, commit]') is incorrect because 'commit' is not a valid GitHub Actions event trigger. The question's answer choices C likely shows the block mapping form, which alongside option A represents the two complete, correct solutions.
Topics
Community Discussion
No community discussion yet for this question.
