Travis CI
Cloud CI for GitHub with .travis.yml, matrix builds, and simple config.
CI/CDBeginner
Why
Travis CI is simple cloud CI with .travis.yml, matrix builds, and free tier for open source. Pioneered cloud CI for GitHub repos.
When
Use Travis for open-source projects on GitHub. Avoid for private (paid, GH Actions better).
How
1. Config — .travis.yml in repo
2. Language — language: node_js
3. Matrix — multiple Node versions
4. Script — install, script, deploy
5. Cache — cache: npm for deps
6. Deploy — deploy: provider: vercel
7. Env — env: global for secrets
Example
# .travis.yml
language: node_js
node_js: [18, 20, 22]
cache: npm
script: [npm ci, npm test, npm run build]
deploy:
provider: script
script: npx vercel --prod --token $VERCEL_TOKEN
on: { branch: main }
env:
global:
- secure: "encrypted-vercel-token" # travis encrypt
Common Problems
- ⚠Build not triggering — enable repo in travis-ci.com
- ⚠Encrypted secrets wrong — use travis encrypt, not raw values
- ⚠Configuration drift between environments — use infrastructure-as-code (Terraform/Pulumi) to keep dev/staging/prod identical
Best Practices
- ✓Use cache: npm — speeds up builds by caching node_modules
- ✓Use travis encrypt for secrets — never commit raw secrets
- ✓Set up health checks and graceful shutdown — handle SIGTERM to drain in-flight requests before exit