Run a deploy only after tests succeed.
Section: Filters and concurrency
Chain jobs with needs
yaml
yaml
jobs:
test:
runs-on: ubuntu-latest
steps:
- run: npm test
deploy:
needs: test
runs-on: ubuntu-latest
steps:
- run: echo "Deploying..."Explanation
`needs` defines job dependencies and helps structure staged pipelines.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Filters and concurrency
Run only when selected paths change
Use `paths` to scope the workflow to files or directories.
Cancel in-progress duplicate runs
Use concurrency groups to keep only the latest run active.