The when block allows you to execute a step only if specific conditions are met. If multiple conditions are listed in a when block, a step executes if at least one condition is true. Within a single condition, all sub-conditions must be true.
Supported Conditions:
repo: Match the repository name.branch: Match the git branch (supports doublestar patterns).event: Match the build event (e.g., push, pull_request, tag, release, cron, manual).ref: Match the git reference (e.g., refs/tags/v*).status: Match the workflow status (success or failure). Default is success.platform: Match the execution platform (e.g., linux/amd64).matrix: Match a specific matrix permutation.instance: Match the Woodpecker instance hostname.path: Match changed files using include or exclude glob patterns (applies to push and pull_request).evaluate: Execute a step based on a boolean expression using the expr syntax (accesses CI_ environment variables).cron: Filter based on the name of a cron job (requires event: cron).
steps:
- name: prettier
image: woodpeckerci/plugin-prettier
when:
- event: pull_request
repo: test/test
- event: push
branch: main