GitHub Actions CI/CD Pipeline
Set up a complete CI/CD pipeline that automatically lints, type-checks, tests, and builds your Next.js or Node.js app on every push and pull request — with optional deployment to Vercel.
Create the Workflows Directory
GitHub Actions reads workflow files from .github/workflows/. Create this directory in your project root.
mkdir -p .github/workflowsCreate the CI Workflow
This workflow runs on every push and pull request to main. It uses a matrix strategy to test against multiple Node.js versions. Jobs run in parallel by default — build waits for test to pass first.
Add a Separate Deploy Workflow
Create a separate workflow that only runs on merges to main. It downloads the build artifact from CI and deploys to Vercel. Using separate files keeps concerns cleanly separated.
Add Required npm Scripts
Make sure package.json has the scripts that the workflows call. lint and test must exit with a non-zero code on failure for the workflow to fail correctly.
Cache Dependencies for Faster Runs
The cache: npm option in actions/setup-node caches ~/.npm automatically. For even faster cache hits, add a cache-dependency-path to scope the cache to your exact lockfile.
Add a Status Badge to README
Paste this markdown into your README.md to show the CI status at a glance. Replace owner and repo with your GitHub username and repository name.
Commit and Push to Trigger the Pipeline
Once you push these files, GitHub automatically detects the workflows and starts the CI run.
git add .github && git commit -m 'ci: add GitHub Actions CI/CD pipeline' && git pushFound this guide helpful? Check out more tools and guides.
Browse All GuidesPrerequisites
- GitHub repository
- Node.js 18+ project with a package.json
- Tests configured (optional but recommended)