Setup
Not actually a full-fledged CI/CD Pipeline at this point. And it goes without saying, but Git for a non-collaborative, personal, static website is overkill. But as long as I am creating a tech blog, it might as well include automatic deployments with version control for a bit of DevOps practice.
Pushing website updates from GitHub to cPanel’s via FTP wasn’t my first approach. I’ll document the less successful process of connecting the GitHub repo to a redundant cPanel Git repo via SSH in a future post.
Process
Started with this 5 minute YouTube tutorial. I wanted something that worked with a private repo, and would build the production site automatically in a shared hosting environment without navigating to the cPanel Git Version Control plugin to manually click on “Deploy HEAD Commit”.
The basic steps in this tutorial are still accurate, two years after its release, but I ran into a lot of trouble with the details.
Basic Steps
- Create the GitHub repo
- Make an FTP account in cPanel and note the username, password, and server address
- Use those to create Action secrets in GitHub, along with a workflow using a deployment script
- Push changes to GitHub, where they hit the Action, authenticate with the Secrets, and get passed along into your folder of choice on the web server
Hurdles
- Had some initial issues figuring out what exactly my FTP server address was
- YouTube tutorial didn’t explain that part
- The cPanel docs said, “FTP does not support Server Name Indication (SNI). You must use the server’s hostname as the FTP server to connect with SSL. You cannot use your domain name.” Which I didn’t realize until later doesn’t apply to my use case
- Double-checked with another, similar tutorial, which said, “…your server IP address (or Hostname but the IP address works…”
- Clicked around in the cPanel plugin until I noticed that clicking “Configure FTP Client” listed out the FTP server address and port, in the format
ftp.yourwebsitedomainname.com
“Error: Input required and not supplied: ftp-server”
- Every time I pushed a change to my repo, the workflow failed
- Googled a lot; assumed I was wrong about the cPanel FTP server address. Tried IP address, shared server hostname, various protocols, including ports…
- Googled the error in quotes. Found the one English-language result. That didn’t help
- Watched the tutorial again, and realized I had been creating Dependabot secrets instead of Action secrets 😑
“Error: The process ‘/usr/bin/git’ failed with exit code 8”
- Workflow failed for a better reason
- Stack Overflow said, “Try: uses: actions/checkout@v4 and uses: \SamKirkland/FTP-Deploy-Action@4.3.3”
- That fixed it; updated script to use the current version of the tool all of these tutorials relied on for the Action workflow
- “Error: Input required and not supplied: server”
- This one was a bit of a soul-crusher. Enough so that I failed to notice the distinction between “ftp-server” and “server”
- Eventually caught on and edited the workflow yml file to reflect the new key names that changed in the last couple of years since these tutorials had been published
“FTPError: 530 Login authentication failed”
- GitHub issue #87 says, “It means your username or password entered is not correct (verify you have no special characters in the username/password)”
- Which was not something I’d heard in any of the tutorials, cPanel, or GitHub docs up to this point
- I created another FTP account without special characters in the username and password (the periods in the server hostname are fine). That one finally went through
Takeaways
- Finding the right tutorial before diving in = Spending 4 hours sharpening the axe
- I probably would have saved time by skimming the first tutorials I found, noticing that they all use the same FTP-Deploy-Action code, and paying closer attention to that repo’s README and Issues pages
Sources
- Auto Deploy Github Project into cPanel - YouTube
- How to Deploy Private GitHub Repositories to cPanel With GitHub Actions
- FTP Accounts | cPanel & WHM Documentation
- Using secrets in GitHub Actions - GitHub Docs
- SamKirkland/FTP-Deploy-Action