Interview Prep/GitHub Actions/Triggers & Events

How do you make one workflow serve both PRs and manual runs with different behaviour?

BeginnerConceptTriggers & Events
Answer

Branch on github.event_name:

on:
  pull_request:
  workflow_dispatch:
    inputs:
      full: { type: boolean, default: false }
jobs:
  test:
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@v4
      - run: npm test -- ${{ (github.event_name == 'workflow_dispatch' && inputs.full) && '--all' || '--changed' }}

inputs.full is null for PR runs, so the expression falls through to --changed.

All GitHub Actions questions Roadmap: GitHub Actions

More on Triggers & Events