Courseiva

Why a GitHub Webhook Trigger Never Fires on Pull Request Events

A developer wants to automatically trigger a GitHub Actions workflow when a pull request is opened that targets the 'release' branch. Which trigger should they use?

⚠ Common exam trap

The trap is confusing `pull_request` with `push` or `pull_request_target`. `push` only fires when code is pushed, not when a PR is opened. `pull_request_target` does fire on PR activity, but it is designed for fork-safe workflows requiring secrets/write permissions; using it without that context is unnecessary and potentially unsafe. The question asks for a trigger when a PR is opened targeting a branch, so `pull_request` is the appropriate choice.

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

✓

pull_request: branches: [release]

The `pull_request` trigger fires when a pull request is opened, and the `branches: [release]` filter restricts it to PRs targeting the `release` branch. `pull_request_target` also fires on PR open events but runs in the base repository context and is intended for workflows requiring secrets or write access, not as the general PR-open trigger. `push` only fires on pushes to branches, not on PR opens. Therefore, D is correct.

Answer analysis

Option-by-option breakdown

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

  • ✗

    pull_request_target: branches: [release]

    Why it's wrong here

    pull_request_target is a security-sensitive trigger that runs in the context of the base repository with access to secrets, intended for safely handling pull requests from forks; it is not the standard trigger for validating PRs and can expose secrets if misused, so it should not be used for a regular PR build.

  • ✗

    push: branches: [release]

    Why it's wrong here

    The push trigger on branches: [release] fires only when commits are directly pushed to the release branch, not when a pull request targeting release is opened or updated; since the developer wants automatic triggering on pull requests, this event type does not match the requirement.

  • ✗

    workflow_dispatch:

    Why it's wrong here

    workflow_dispatch is a manual trigger that requires a user to select the workflow in the GitHub UI or invoke the repository dispatch API; it does not respond to automated events like pull_request or push, so it will not automatically start the workflow as needed.

  • ✓

    pull_request: branches: [release]

    Why this is correct

    The pull_request trigger with branches: [release] is the standard and correct event for running a workflow whenever a pull request is opened, updated, or reopened against the release branch; it automatically validates the PR's merged result and meets the requirement precisely.

About these practice questions

Courseiva writes every AZ-400 question from scratch — 696 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

1 more way this is tested on AZ-400

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. Your development team uses GitHub for source control. You want to automatically run a set of tests every time a pull request is opened against the main branch. What should you configure?

easy
  • ✓ A.Create a GitHub Actions workflow triggered by pull_request events to main
  • B.Use the GitHub API to trigger tests when a PR is opened
  • C.Set up a webhook to trigger an external CI system
  • D.Configure a branch protection rule to require status checks

Why A: GitHub Actions natively supports the `pull_request` event trigger, which can be configured to run workflows automatically when a pull request is opened against a specific branch (e.g., `main`). This allows you to define a YAML-based workflow in the `.github/workflows` directory that executes tests on every PR event, providing immediate feedback to developers without requiring external services or manual API calls.

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

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.