GitHub actions allows to make use of your GitHub-hosted code
repositories for running custom scripts for testing, deployment, and
much more.
Before You Get Started (Some Caveats and Prerequisites)
(Basically) How GitHub Actions Work
How to set up the GitHub FTP Action
Deploy Files to Unmanaged VPS Cloud Server With SCP (Added Security)
set up 2-factor authentication; which will add another layer of security on top of
your default username/password combination.
If you are interested in how to deploy files to your unmanaged VPS without using GitHub as a hosted service, check out our full guide on how to publish files to your server using Git.
ftp-deploy” action is ideal for deploying files to your
WordPress, shared hosting, or cPanel managed VPS accounts.
However, for cloud servers, the SCP method is recommended.
Edit the .github/workflows/main.yml file and place this code inside:
The file path set for the “ftp-server” option lands in “public_html”
directory; make sure to update this as necessary for your project,
or leave it as is to drop your project files in that directory.
The username “userna5” must be substituted with your correct cPanel
or FTP username.
Alternatively, you could use a GitHub secret for your username in
the same fashion as the FTP password.
Before committing and pushing your code to the repository, make sure
you have substituted all of the placeholder values, including
“FTP_PASSWORD” secret.
scp-action” action available from the GitHub website, SCP
offers an extra layer of security with SSH keys.
By default, your InMotion Hosting cloud VPS does not allow root login
via password authentication. SSH key authentication provides your
only way in. In order to allow GitHub to copy files to your server,
you will need to add your SSH private key and secure passphrase as a
GitHub secret, and, optionally, your username (which would be “root” by
default), hostname (or IP address).
As with the FTP action, this action will trigger on the GitHub server
when you push your changes to the repository.
Well done, you now know how to run GitHub actions for file deployment
with both the FTP and SCP file transfer methods. Be sure to leave a
comment or question if you have any issues or suggestions.