Engineering a CI/CD Pipeline with GitHub Actions and AWS EC2 published

Engineering a CI/CD Pipeline with GitHub Actions and AWS EC2 publishedJesse James Kyemting

Introduction As developers and infrastructure engineers, we strive to eliminate...

Introduction

As developers and infrastructure engineers, we strive to eliminate repetitive manual tasks. When it came time to host my interactive, terminal-themed portfolio website, running manual file transfers or standard SSH updates felt like a missed architectural opportunity.

I wanted a modern engineering workflow: write code locally, push to a remote repository, and let automated pipelines handle the heavy lifting.

Here is a comprehensive technical breakdown of how I designed and engineered a lean Continuous Deployment (CD) pipeline utilizing GitHub Actions and an AWS EC2 infrastructure, along with the real-world debugging lessons I learned along the way.


🔗 Check out the complete codebase and workflow configurations on GitHub.

The Architectural Blueprint

The pipeline is built on an automated, event-driven loop that links a local development environment to an active production server in the cloud:


mermaid
graph LR
    Dev[\"💻 Local Workspace (WSL)"/] -- git push --> Repo[("(fa:fa-github) GitHub Remote Repo")]
    Repo ==> Trigger{{"⚡ Workflow Runner Trigger"}}
    GHA[["🔧 job: deploy_site"]] --- Secrets[/"🔑 GitHub Encrypted Secrets"\]
    Trigger --> GHA
    GHA -- Secure SSH Tunnel --> EC2["🐧 AWS EC2 Ubuntu Instance"]
    EC2 -- git fetch & hard reset --> App[/"📁 Apache Root (/var/www/html)"/]
    App == Deployment Status 200 OK ==> Web(("🌐 Production Live Site"))

    style Dev fill:#eceff1,stroke:#37474f,stroke-width:2px
    style Repo fill:#e1f5fe,stroke:#0288d1,stroke-width:2px
    style Trigger fill:#fff3e0,stroke:#f57c00,stroke-width:2px
    style GHA fill:#ede7f6,stroke:#5e35b1,stroke-width:2px
    style Secrets fill:#ffebee,stroke:#c62828,stroke-width:1px,stroke-dasharray: 5 5
    style EC2 fill:#efebe9,stroke:#4e342e,stroke-width:2px
    style App fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px
    style Web fill:#e8f8f5,stroke:#117a65,stroke-width:3px
Enter fullscreen mode Exit fullscreen mode