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.
More on Triggers & Events
How do you trigger a workflow on pushes to `main` and on PRs that target `main`?BeginnerWhat activity types does `pull_request` trigger on by default, and how do you add more?IntermediateHow do `branches` and `branches-ignore` filters work with globs?BeginnerHow do path filters work, and what are their limits?AdvancedHow do you trigger only on version tags, and what is the gotcha with pushing many tags?IntermediateWhat is `workflow_dispatch`, and what input types does it support?Beginner