Hosting Resume on AWS EC2 Instance with CI/CD Setup using GitHub Actions

Learn how to host your resume on an AWS EC2 instance and automate deployment using GitHub Actions.

Step #1: Go to EC2 from AWS Console

Log in to your AWS Management Console and navigate to the EC2 dashboard.

Step #2: Create a New Security Group

Step #3: Create EC2 Instance

Step #4: GitHub Repository

Create a new GitHub repository and upload the files for your resume (e.g., index.html, style.css, etc.).

Step #5: Secrets and Variables for CI/CD

Step #6: GitHub Actions

name: Push-to-EC2

# Trigger deployment only on push to main branch
on:
  push:
    branches:
      - main

jobs:
  deploy:
    name: Deploy to EC2 on master branch push
    runs-on: ubuntu-latest

    steps:
      - name: Checkout the files
        uses: actions/checkout@v2

      - name: Deploy to Server 1
        uses: easingthemes/ssh-deploy@main
        env:
          SSH_PRIVATE_KEY: ${{ secrets.EC2_SSH_KEY }}
          REMOTE_HOST: ${{ secrets.HOST_DNS }}
          REMOTE_USER: ${{ secrets.USERNAME }}
          TARGET: ${{ secrets.TARGET_DIR }}

      - name: Executing remote ssh commands using ssh key
        uses: appleboy/ssh-action@master
        with:
          host: ${{ secrets.HOST_DNS }}
          username: ${{ secrets.USERNAME }}
          key: ${{ secrets.EC2_SSH_KEY }}
          script: |
            sudo apt-get -y update
            sudo apt-get install -y apache2
            sudo systemctl start apache2
            sudo systemctl enable apache2
            cd home
            sudo mv * /var/www/html
            

Click Commit Changes

Continuous Integration / Continuous Deployment (CI/CD)

After setting up the above steps, any change committed to the Code will automatically reflect on the instance.

Facing Difficulties?

Go to this Repository