Loading...
+880 1736 699819 Mon - Sat: 9:00 AM - 8:00 PM
Follow us:
Home Blog Article
Blog

CI/CD with GitHub Actions Tutorial – Complete Beginner to Advanced Guide

CI/CD with GitHub Actions Tutorial – Complete Beginner to Advanced Guide

CI (Continuous Integration):
Automatically builds and tests your code whenever you make changes.

CD (Continuous Deployment / Delivery):
Automatically deploys your code to a server or hosting platform after it passes tests.

Create a Workflow File

.github/workflows/ci.yml

 Basic CI Workflow

name: Simple CI

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'

      - name: Install dependencies
        run: npm install

      - name: Build project
        run: npm run build

Run Tests Automatically

      - name: Run Tests
        run: npm test

Add CD (Deployment) – Simple Example

      - name: Deploy to Server
        uses: appleboy/ssh-action@v1
        with:
          host: ${{ secrets.SSH_HOST }}
          username: ${{ secrets.SSH_USER }}
          key: ${{ secrets.SSH_KEY }}
          script: |
            cd /var/www/project
            git pull origin main
            npm install
            npm run build

Using GitHub Secrets

SSH_HOST
SSH_USER
SSH_KEY

${{ secrets.SSH_HOST }}
Tags: Blog
Share this post

Encoderbase Team

Author

Articles and insights from the Encoderbase editorial team covering web development, software engineering, and digital solutions.

Enjoyed this article?

Get more articles like this delivered to your inbox — no spam, unsubscribe any time.

Link copied to clipboard!