Git & GitHub Interview Question #87

What are events or triggers in GitHub Actions?

GitHub Collaboration, Repository Rules, Issues, Releases & Actions CI/CD Mid-Level Intermediate

Quick Interview Answer

Events determine when a workflow should run. Common triggers include push, pull_request, workflow_dispatch, schedule, release, and other repository activity.

Detailed Explanation

Events determine when a workflow should run. Common triggers include push, pull_request, workflow_dispatch, schedule, release, and other repository activity.

Triggers can often be filtered by branches, tags, or paths. Careful filtering avoids running expensive workflows when unrelated files change.

Code Example

name: PR Validation

on:
  pull_request:
    branches:
      - main
    paths:
      - "src/**"
      - "tests/**"

jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - run: echo "Validate pull request"