Back
📦Automationgeneric
GitHub Actions CI/CD Pipeline
A complete GitHub Actions workflow generator for Next.js apps. Includes testing, linting, building, and deployment to Vercel or Docker.
by DevOpsPro·36 days ago·
CI/CDGitHub ActionsdeploymentDevOpsautomation
Generate a GitHub Actions workflow YAML for a Next.js application with the following pipeline:
```yaml
name: CI/CD Pipeline
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
NODE_VERSION: '20'
jobs:
# Job 1: Lint & Type Check
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- run: npm ci
- run: npm run lint
- run: npm run check-types
# Job 2: Tests
test:
needs: quality
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- run: npm ci
- run: npm test -- --coverage
- uses: codecov/codecov-action@v4
if: always()
# Job 3: Build & Deploy
deploy:
needs: test
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- run: npm ci
- run: npm run build
- name: Deploy
run: echo "Add your deployment step here"
```
Customize: database service, deployment target, env vars, and test runner.