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:
Step 1: Generating SSH Keys
SSH keys allow secure communication between your GitHub repository and Bluehost server. Follow these steps to generate SSH keys:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
This command creates a new SSH key pair:
Add SSH Key to GitHub:
cat ~/.ssh/id_rsa.pub
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:
Recommended by LinkedIn
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:
Step 4: Troubleshooting Common Issues
Issue: SSH Port 22 Blocked on Bluehost Shared Hosting
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.