Interview Prep/CI/CD/GitHub Actions

A job needs to run only when a label such as `deploy-preview` is on the PR.

BeginnerScenarioGitHub Actions
Answer

Situation read → Conditional job on PR metadata.

What I'd do →

on:
  pull_request:
    types: [opened, synchronize, labeled]
jobs:
  preview:
    if: contains(github.event.pull_request.labels.*.name, 'deploy-preview')

Why → labeled must be in types or adding the label will not trigger a run.

Interview tip → Default PR types are opened, synchronize and reopened.

All CI/CD questions

More on GitHub Actions