🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now β†’
Menu

Categories

Building a CI/CD Pipeline with GitHub Actions: From Zero to Auto-Deploy

Building a CI/CD Pipeline with GitHub Actions: From Zero to Auto-Deploy

GitHub Actions provides a powerful, free CI/CD platform built into your repository.

CI Workflow

name: CI Pipeline
on:
  push:
    branches: [main, develop]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm ci
      - run: npm test

Docker Build

  build:
    needs: test
    steps:
      - uses: docker/build-push-action@v5
        with:
          push: true
          tags: ghcr.io/${{ github.repository }}:${{ github.sha }}

Multi-Environment Deploy

  deploy-staging:
    needs: build
    environment: staging
    steps:
      - run: ssh deploy@staging "docker compose up -d"

  deploy-production:
    needs: deploy-staging
    environment: production
    steps:
      - run: ssh deploy@prod "docker compose up -d"

Master DevOps with our DevOps eBook collection.

Share this article:
Dargslan Editorial Team (Dargslan)
About the Author

Dargslan Editorial Team (Dargslan)

Collective of Software Developers, System Administrators, DevOps Engineers, and IT Authors

Dargslan is an independent technology publishing collective formed by experienced software developers, system administrators, and IT specialists.

The Dargslan editorial team works collaboratively to create practical, hands-on technology books focused on real-world use cases. Each publication is developed, reviewed, and...

Programming Languages Linux Administration Web Development Cybersecurity Networking

Stay Updated

Subscribe to our newsletter for the latest tutorials, tips, and exclusive offers.