How to setup CICD pipeline in Github Actions for Godaddy
Nowadays it is very common to use Continuous Deployment whether it’s a Personal Hobby website or Enterprise application. It’s tedious to make the code change, log in to the server, and then copy the changed/compiled files manually into the server. It is always good to automate and create a pipeline so that whenever there is a code commit in the version control system (e.g. Github) the pipeline will trigger and do the automatic deployment.
GitHub provides Action for the automatic deployment purpose. Let’s see how to utilize Github action and do automatic code deployment in a shared hosting like Godaddy.
First, create an FTP account in GoDaddy accounts from cpanel. From the GitHub action, the system will log in to the FTP location and copy the files.
Now it’s time to set up Github action for automatic deployment on code push. In the GitHub repository create a file in /.github/workflows/main.yaml. In this file, the continuous integration instructions will be written.
The process will run when any code is pushed to the repository (in this case main branch). The commands will run on a Ubuntu server (provisioned by GitHub Action) that checkout the latest code and copies it to the mentioned FTP location. Server details and credentials will be taken from Github Secrets.
Now we have to create a username and password in the GitHub Secret Manager
Open the GitHub repository -> Settings -> Secret and variables -> Actions -> New repository secrets
Create the secrets named ftp_hostname, ftp_username, and ftp_password with the corresponding FTP username and password generated in the Godaddy portal.
Whenever there will be a code push in the main repository, the deployment will happen by GitHub Actions.
GitHub cannot resolve the FTP location: Initially, GitHub cannot resolve the FTP location of my Godaddy website. I had a chat with Godaddy support. It was identified, that I am using CloudFlare as a proxy for my Website SSL certification the A record needs to be added in the CloudFlare.
Files are not created in the correct folder in the server: While creating the home directory of the FTP user please choose the FTP user home directory carefully. The location of server-dir in main.yaml file will consider the home location of the path. You might need to change the default home directory of the FTP user provided by Godaddy. I had to change it to make my configuration work.