GitHub to Web Hosting
You can deploy private GitHub repo to cPanel, Hostinger, or any Web Hosting Manager. Automatic deployment for your CI/CD. This method will work for that. I'm a web developer by profession, I face this issue a lot until I find this method.
Deploying while cPanel Git version control you will face the issue "GitHub cannot access private repository" while submitting Github private repo unless until you setup a private key of cPanel to your GitHub Deploy keys.
Here you don't need to have SSH access or any root access for this method. All you need is an FTP ACCOUNT.
Let's start
In this method, I will be using the Deployment of GitHub Private Repo to cPanel.
1. You have to create an FTP account.
You need to setup the following details.
Log In: it will be the username
Log In: it will be the username
Domain: it will be your domain name.
Password: Write a password whatever you like. But keep it safe we will use re-use it, in github.
3. Now go to your repository Settings > Secrets > Actions and click on New repository secret.
Name: FTP_SERVERValue: YOUR_FTP_SERVER_ADDRESSName: FTP_USERNAMEValue: YOU_FTP_USERNAMEName: FTP_PASSWORDValue: YOUR_FTP_PASSWORD
In my case its
Name: FTP_SERVERValue: ftp.recmail.netName: FTP_USERNAMEValue: admin_github@blog.hit4visit.comName: FTP_PASSWORDValue: s^E7tXj+O00U
5. Now add an action workflow. Change its name from main.yml to cPanelDepolyment.yml
Copy the code below and add it to the workflow, click on start commit and then commit new file.
Version 1 code:
name: Publish Website to Web Hosting on: push: branches: - main jobs: FTP-Deploy-Action: name: FTP-Deploy-Action runs-on: ubuntu-latest steps: - uses: actions/checkout@v2.1.0 with: fetch-depth: 2 - name: FTP-Deploy-Action uses: SamKirkland/FTP-Deploy-Action@3.1.1 with: ftp-server: ${{ secrets.FTP_SERVER }} ftp-username: ${{ secrets.FTP_USERNAME }} ftp-password: ${{ secrets.FTP_PASSWORD }}
Version 2 code:
name: Publish Website to Web Hosting V2 on: push: branches: - main jobs: web-deploy: name: 🎉 Deploy runs-on: ubuntu-latest steps: - name: 🚚 Get latest code uses: actions/checkout@v2 - name: 📂 Sync files uses: SamKirkland/FTP-Deploy-Action@4.3.0 with: server: ${{ secrets.FTP_SERVER }} username: ${{ secrets.FTP_USERNAME }} password: ${{ secrets.FTP_PASSWORD }}And boom, now you can do CI/CD of your project. Now, wait a few minutes until it deploys its initial code, after that once you push to the branch your setup, for older "master" or new version "main" or whatever you setup as default or you want its push to be updated, it will automatically update on your website.
I could not get the files to the desired directory
ReplyDeleteIt maybe because you didn't set directory properly in FTP.
DeleteThe process '/usr/bin/git' failed with exit code 5
ReplyDeleteLooks like you use sftp, try to use ftp.
DeleteNew code updated try again!
DeleteThe process '/usr/bin/git' failed with exit code 5.
ReplyDeleteSame error here.
Tried also: ftp://${{ secrets.FTP_SERVER }}:21/
nothing changed. Any ideas?
This is a strange error! It remove when I just modify the action, by adding a space at then end of the file and save it.
DeleteNew code updated try again!
Delete