Setting Up CI/CD for GitHub Project to Bluehost Shared Hosting

Setting Up CI/CD for GitHub Project to Bluehost Shared Hosting

Deploying your web application from GitHub to Bluehost shared hosting can streamline your development workflow through Continuous Integration/Continuous Deployment (CI/CD). This guide will walk you through the process step-by-step, including generating SSH keys, configuring GitHub Actions, and troubleshooting common issues.

Prerequisites

Before starting, ensure you have the following:

  • A web application hosted on GitHub.
  • Access to a Bluehost shared hosting account.
  • Basic understanding of Git, SSH, and command line

Step 1: Generating SSH Keys

SSH keys allow secure communication between your GitHub repository and Bluehost server. Follow these steps to generate SSH keys:

  1. Open Terminal (Linux/Mac) or Git Bash (Windows):

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"        

This command creates a new SSH key pair:

  • id_rsa: Private key (store securely and do not share).
  • id_rsa.pub: Public key (share with services like GitHub).

Add SSH Key to GitHub:

  • Copy the contents of the public key (id_rsa.pub):

cat ~/.ssh/id_rsa.pub        


  1. Go to your GitHub account → Settings → SSH and GPG keys → New SSH key.

Step 2: Configuring SSH Access on Bluehost

Bluehost restricts direct SSH access on port 22 for shared hosting. Follow these steps to enable SSH access via cPanel:

  1. Log in to Bluehost cPanel:

Step 3: Setting Up GitHub Actions

GitHub Actions automates the deployment process. Create a workflow file (deploy.yml) in your GitHub repository under .github/workflows/:

Sample .github/workflows/deploy.yml file:

name: Deploy to Bluehost

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Install dependencies
        run: npm install

      - name: Build application
        run: npm run build

      - name: Deploy to Bluehost
        uses: easingthemes/ssh-deploy@v2.2.7
        with:
          server: your-bluehost-domain.com
          username: bluehost-username
          password: ${{ secrets.BLUEHOST_PASSWORD }}
          local_path: ./build
          remote_path: public_html
        

Replace placeholders:

  • your-bluehost-domain.com: Your Bluehost domain.
  • bluehost-username: Your Bluehost username.
  • ./build: Path to your built files (adjust as per your project structure).
  • public_html: Remote path on Bluehost where your site will deploy.

Step 4: Troubleshooting Common Issues

Issue: SSH Port 22 Blocked on Bluehost Shared Hosting

  • Solution: Bluehost restricts direct SSH access on port 22. Enable SSH access via cPanel and use an SSH key for authentication.

Conclusion

Setting up CI/CD from GitHub to Bluehost shared hosting enhances your development workflow by automating deployments. By generating SSH keys, configuring GitHub Actions, and troubleshooting common issues like port access, you can ensure a seamless deployment process.

Implement these steps to leverage CI/CD for efficient and secure web application deployment on Bluehost shared hosting.


Issue Faced:

During the setup, I encountered an issue with SSH port 22 being blocked on Bluehost's shared hosting environment. Bluehost restricts direct SSH access on port 22, which required me to enable SSH access via cPanel and use alternative methods for secure deployments.

Solution:

To resolve this issue, I utilized the SSH Deploy GitHub Action (easingthemes/ssh-deploy) which allows deployment via SSH without direct port 22 access. Additionally, I configured SSH keys and added them to Bluehost's authorized keys list through cPanel to ensure secure and reliable deployments.


To view or add a comment, sign in

More articles by Senthil Gopal

Others also viewed

Explore content categories