DevOps • CI/CD • Automated Deployment
How I Built My CI/CD Pipeline
Problem Statement
Manually uploading files to the server using SSH was time-consuming and error-prone. I wanted an automated way to deploy changes instantly after code updates to improve reliability and speed.
VS Code
GitHub
GitHub Actions
SSH
Oracle VM
Web Server
1
Step 1: Initialize Git Repository and Push Code
Establishing a clean version control workflow on GitHub is the foundation of any CI/CD strategy.
2
Step 2: Add Workflow YAML
I created a .github/workflows/deploy.yml file to automate the deployment logic.
name: Remote SSH Deploy
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Executing remote ssh commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
cd /home/ubuntu/your-repo
git pull origin main
sudo cp -r * /var/www/html/
Workflow Explanation:
- The workflow triggers automatically on every push to the main branch.
- It connects to my Oracle VM via SSH using a secure private key stored in GitHub Secrets.
- It executes a shell script to pull the latest code and sync it with the Nginx web directory.
3
Step 3: Configure Server Secrets
Security is paramount. Sensitive data like the VM's IP address and SSH Private Keys are stored in GitHub Secrets to prevent exposure.
Key Learnings
- GitHub Actions can automate deployments without complex external tools like Jenkins.
- SSH-based deployment is a simple, lightweight, and effective solution for small-to-medium cloud projects.
- CI/CD pipelines drastically reduce manual human error and improve system reliability.