Phase Pipeline
Phase-based pipeline using phase metadata — source, deps, build, test, deploy
An example of using the phase field to visually distinguish pipeline stages on the dashboard. 9 Jobs progress in order: source → deps → build → test → deploy.
Full Code
name: phase-full-pipeline
triggers:
push:
branches: [main]
jobs:
# ═══════════════════════════════════════
# Phase: source — Source code checkout
# ═══════════════════════════════════════
source-checkout:
phase: source
steps:
# Code checkout
- name: checkout-code
uses: "collabops/checkout@v2"
with:
repo-url: "https://<collabops-host>/<workspace>/<repository>.git"
submodules: "recursive"
# ═══════════════════════════════════════
# Phase: deps — Dependency installation + cache
# ═══════════════════════════════════════
deps-install:
phase: deps
needs: [source-checkout]
steps:
- name: install-dependencies
image: node:18
run: npm ci
env:
NODE_ENV: production
- name: cache-dependencies
image: node:18
run: npm cache verify
# ═══════════════════════════════════════
# Phase: build — App build + Docker image
# ═══════════════════════════════════════
build-app:
phase: build
needs: [deps-install]
services:
- docker
steps:
- name: compile-app
image: node:18
run: npm run build
env:
BUILD_ENV: production
- name: build-docker-image
image: docker:27.5-cli
run: docker build -t myapp:latest .
# ═══════════════════════════════════════
# Phase: test — Unit/Integration tests (parallel)
# ═══════════════════════════════════════
# Unit tests + coverage
test-unit:
phase: test
needs: [build-app]
steps:
- name: run-unit-tests
image: node:18
run: npm run test:unit
- name: generate-coverage
image: node:18
run: npm run coverage
# Integration tests
test-integration:
phase: test
needs: [build-app] # Runs in parallel with test-unit
steps:
- name: run-integration-tests
image: node:18
run: npm run test:integration
# ═══════════════════════════════════════
# Phase: test — Security scan (parallel with tests)
# ═══════════════════════════════════════
security-scan:
phase: test
needs: [build-app] # Runs in parallel with tests
steps:
# Dependency vulnerability scan
- name: vulnerability-scan
image: node:18
run: npm audit --audit-level=high
# Static analysis security scan
- name: sast-scan
image: node:18
run: npm run security:scan
# License compatibility check
- name: license-check
image: node:18
run: npm run license:check
# Security approval wait
security-approval:
phase: test
needs: [security-scan]
steps:
- name: wait-for-approval
run: echo "Security scan passed — proceeding to deploy"
# ═══════════════════════════════════════
# Phase: deploy — Staging → Production
# ═══════════════════════════════════════
# Staging deployment — After all tests + security pass
deploy-staging:
phase: deploy
needs: [test-unit, test-integration, security-approval]
steps:
- name: deploy-to-staging
run: kubectl apply -f k8s/staging/
env:
DEPLOY_ENV: staging
- name: health-check
run: |
echo "Running health check..."
curl -f http://staging.example.com/health
# Production deployment — After staging verification
deploy-production:
phase: deploy
needs: [deploy-staging]
if: "collabops.ref == 'refs/heads/main' && collabops.event_name == 'push'"
steps:
- name: deploy-to-production
run: kubectl apply -f k8s/production/
env:
DEPLOY_ENV: production
- name: health-check
run: curl -f http://production.example.com/health
- name: notify-deployment
uses: "collabops/slack-notify@v1"
with:
webhook-url: ${{ secrets.SLACK_WEBHOOK }}
message: "Production deployment complete: ${{ collabops.sha }}"
color: goodPhase-to-Job Mapping
| Phase | Jobs | Description |
|---|---|---|
source | source-checkout | Source code checkout |
deps | deps-install | Dependency installation and caching |
build | build-app | App build + Docker image |
test | test-unit, test-integration, security-scan, security-approval | Tests + security (parallel) |
deploy | deploy-staging, deploy-production | Staging → Production |
Execution Flow
source-checkout
└── deps-install
└── build-app
├── test-unit ──────────────┐
├── test-integration ────────┼── deploy-staging ── deploy-production
└── security-scan │
└── security-approval ┘Key Points
phase is metadata for visually distinguishing stages on the dashboard.
Execution order is controlled by needs. phase does not affect execution behavior.
Jobs with the same phase can still run at different times if their needs differ.
Available phases: source, deps, build, test, security, deploy