CI/CD with GitHub Actions

Anne VAnne V
1 min read
Share

Automate Your Pipeline

GitHub Actions makes it easy to automate testing, building, and deploying your code. Let's set up a complete CI/CD pipeline.

Basic Workflow

name: CI/CD

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm
      - run: npm ci
      - run: npm test
      - run: npm run build

  deploy:
    needs: test
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: ./deploy.sh

This workflow runs tests on every PR and deploys on merge to main.

Comments

Anne V
Anne V

Full-stack developer passionate about React, TypeScript, and building great developer experiences. Currently working on AI-powered tools.