Courseiva
Question 244 of 823
Design and implement a source control strategyeasyMultiple ChoiceObjective-mapped

AZ-400 Practice Question: Design and implement a source control strategy

You have a GitHub repository with a GitHub Actions workflow that builds a .NET application. The workflow should only run when changes are pushed to the main branch, but it currently runs on every push to any branch. How should you fix the workflow trigger?

⚠ Common exam trap

Many candidates confuse the singular `branch` with the plural `branches` or mix up `paths` with `branches`, leading them to select options that either use invalid syntax or apply the wrong filter entirely.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Add 'on: push: branches: [main]' to the workflow.

The GitHub Actions workflow syntax to restrict a push trigger to a specific branch uses `on: push: branches: [main]`. This ensures the workflow only executes when commits are pushed to the main branch, not on pushes to any other branch.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Add 'on: push: branch: [main]' to the workflow.

    Why it's wrong here

    Using 'branch' (singular) is invalid YAML syntax for GitHub Actions; the correct key is 'branches' (plural), which expects a list of branch name patterns. With 'branch', GitHub will ignore the filter or the workflow may fail validation, so the workflow would not trigger as intended.

  • Add 'on: push: paths: [main]' to the workflow.

    Why it's wrong here

    The 'paths' filter is used to trigger workflows based on file paths changed in the push, not on branch names. To restrict the workflow to a specific branch like 'main', you must use the 'branches' key under 'push', not 'paths'.

  • Add 'on: pull_request: branches: [main]' to the workflow.

    Why it's wrong here

    The 'pull_request' trigger fires when pull request events occur (opened, synchronized, etc.), not when code is pushed to a branch. To run the workflow on pushes to 'main', you need to use the 'push' event with a 'branches' filter, not 'pull_request'.

  • Add 'on: push: branches: [main]' to the workflow.

    Why this is correct

    This correctly configures the 'push' trigger with the 'branches' filter set to 'main', using the proper plural key. As a result, the workflow will execute only when commits are pushed directly to the 'main' branch, ignoring pushes to other branches.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jun 25, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

This AZ-400 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-400 exam.