Laravel CI/CD Implementation on cPanel Shared Hosting Using Github Actions

Morris Muriuki Muthigani
35
0
laravel

01/12/2024 (5 months ago)


Abstract:

This article provides a guide on deploying a Laravel project on shared hosting with cPanel, utilizing Github Actions for Continuous Integration/Continuous Deployment (CI/CD) in scenarios where SSH access is restricted.

Introduction:

Shared hosting is a cost-effective alternative to VPS, but some hosting providers may limit SSH access for various reasons. Despite this limitation, FTP access is often available. This article demonstrates how to leverage Github Actions and FTP to establish a CI/CD pipeline for deploying Laravel projects on shared hosting without SSH access.

Getting Started:

Follow these step-by-step instructions:

1. Setting up FTP Account

Step 1: Log in to your cPanel and navigate to FTP Account.


2. Adding the FTP Account:

Step 2: Create a new FTP account by following the provided options in the cPanel.

3. Retrieving FTP Account Details:

Step 3: Access the FTP Client within cPanel to retrieve the necessary account details.


4. Copy and Save FTP Credentials:

Step 4: Copy the FTP Username and FTP Server information obtained from the FTP Client and securely save it for future use in the CI/CD setup.



Setting up GitHub Actions for Laravel CI/CD with cPanel Shared Hosting:

Step 1: Open the GitHub repository you wish to automate and navigate to the "Actions" tab.


Step 2: Click on the highlighted link within the Actions tab.

Step 3: Access Settings and go to Actions under the Secrets and Variables dropdown.

Step 4: Create a new repository secret, utilizing the FTP account values obtained earlier.

To maintain security, sensitive server access information should not be included in the source code. GitHub provides a solution by allowing developers to pass critical variables securely. Open the repository settings, navigate to the Security section, and click on Secrets and Variables. Under Actions, insert SERVER, USERNAME, and PASSWORD.

Step 5: Copy the provided YAML file and save it as main.yml, then commit the changes.
main.yml

Completion: The CI/CD pipeline is now set up. By pushing or merging new code into the main branch, the CI/CD process will be triggered.

Hint: The initial setup may take some time, but subsequent executions will be faster.


Discussion (0)

Recent Blogs

Our Recent Blogs