Deploying with Semaphore
High-performance CI/CD with auto-scaling runners and YAML-based pipelines.
CI/CDIntermediate
Why
Semaphore is optimized for speed with auto-scaling runners and fast caching, ideal for large test suites. DORA's 2024 State of DevOps report shows elite teams deploy 973x more frequently than low performers.
CI/CD pipelines with automated testing reduce change failure rate to 5-15% versus 40-60% for manual deployments.
When
Projects needing fast CI with auto-scaling and monorepo support. Avoid complex pipeline orchestration for repos with fewer than 5 contributors — a pre-commit hook + GitHub Actions suffices.
Skip self-hosted runners unless you need GPU or VPN access.
How
# .semaphore/semaphore.yml
version: v1.0
name: CI Pipeline
agent:
machine:
type: e1-standard-2
os_image: ubuntu2004
blocks:
- name: Build
task:
jobs:
- name: npm build
commands:
- checkout
- npm ci
- npm run build
- cache store build dist/
- name: Deploy
dependencies: ["Build"]
task:
jobs:
- name: deploy
commands:
- checkout
- cache restore build
- kubectl apply -f k8s/
4. Verify deployment — curl -I https://your-app.example.com
5. Monitor logs — check for errors in first 5 minutes
6. Rollback if needed — revert to previous version
Example
// config — deploy-semaphore
const config = require("./config");
# Semaphore promotion (auto-deploy on main)
promotions:
- name: Deploy to production
pipeline_file: deploy.yml
auto_promote_on:
- result: passed
branch:
- main
Common Problems
- ⚠Cache miss — ensure cache store/restore keys match
- ⚠Runner queue — increase agent machine type
- ⚠Configuration drift between environments — use infrastructure-as-code (Terraform/Pulumi) to keep dev/staging/prod identical
Best Practices
- ✓Use monorepo project analysis — only run affected blocks
- ✓Use auto-promotion — deploy automatically on merge to main
- ✓Set up health checks and graceful shutdown — handle SIGTERM to drain in-flight requests before exit