# CI/CD with GitHub Actions

> Run lint, type checks, tests and builds on every pull request, and deploy automatically when main is green. Free notes, key concepts, resources and a mini...

Canonical: https://www.internhack.in/roadmaps/tracks/full-stack/ci-cd
Last updated: 2026-11-28

Run lint, type checks, tests and builds on every pull request, and deploy automatically when main is green.

Intermediate · about 5 hours · difficulty 3/5

Learn first: [Git and GitHub](https://www.internhack.in/roadmaps/tracks/full-stack/git-and-github), [API Integration Tests with a Real Database](https://www.internhack.in/roadmaps/tracks/full-stack/api-integration-testing), [Environments, Config and Secrets](https://www.internhack.in/roadmaps/tracks/full-stack/environment-and-config)

**Continuous integration** means every push is checked automatically. **Continuous delivery** means a green main branch can go to production without manual steps. Together they let small teams ship daily without fear.

### A typical pipeline

1. Install dependencies with a cached npm ci.
2. Lint and type-check (tsc --noEmit).
3. Run unit and integration tests, with PostgreSQL as a **service container**.
4. Build the app.
5. On main only: apply migrations and deploy (or let Vercel or Render deploy on push once checks pass).

### GitHub Actions basics

- Workflows live in .github/workflows as YAML files.
- **Triggers**: push, pull_request, schedule, manual dispatch.
- **Jobs** run on fresh runners; **steps** run commands or reusable actions.
- **Secrets** are stored in repository settings and injected as environment variables.
- **Branch protection** requires checks to pass before merging.

### Keep it fast

Cache dependencies, run independent jobs in parallel, and keep slow E2E tests in a separate job. A pipeline that takes 20 minutes gets ignored.

### Pitfalls

- Printing secrets in logs.
- Flaky tests that everyone reruns until green, which hides real failures.
- Deploying from a laptop instead of from CI.

You are ready to move on when every pull request on your project runs lint, type checks, tests against PostgreSQL and a build, and main deploys automatically only when all checks pass.

## Key concepts

- **Workflows, jobs and steps**
- **Triggers: push and pull_request**
- **Dependency caching**
- **Service containers for PostgreSQL**
- **Secrets in CI**
- **Branch protection**
- **Automated deploys and migrations**
- **Dependabot**

## Mini project

Create a GitHub Actions workflow for your portal that caches dependencies, lints, type-checks, runs tests against a PostgreSQL service container, builds, and blocks merges to main unless all checks pass.

## Check yourself

Why run tests against a real PostgreSQL service in CI instead of mocking the database?

## Free resources

- [GitHub Actions documentation](https://docs.github.com/en/actions) (GitHub)
- [Building and testing Node.js](https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-nodejs) (GitHub)
- [DevOps Roadmap](https://roadmap.sh/devops) (roadmap.sh)

Previous: [Managed Databases, Domains and HTTPS](https://www.internhack.in/roadmaps/tracks/full-stack/managed-postgres-and-domains) · Next: [Logging, Error Tracking and Monitoring](https://www.internhack.in/roadmaps/tracks/full-stack/logging-and-monitoring)

## More in CI, Observability and Performance

- [CI/CD with GitHub Actions](https://www.internhack.in/roadmaps/tracks/full-stack/ci-cd)
- [Logging, Error Tracking and Monitoring](https://www.internhack.in/roadmaps/tracks/full-stack/logging-and-monitoring)
- [Web Performance and Core Web Vitals](https://www.internhack.in/roadmaps/tracks/full-stack/web-performance)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Full-Stack Developer Roadmap](https://www.internhack.in/roadmaps/tracks/full-stack)
