I need help setting up a GitHub workflow so anytime I push to my GitHub repository the changes will be automatically pushed to my cpanel repository. I think this will be a better option than pushing to both GitHub and cpanel repository. This will also be helpful when multiple developers are working on the project and I would not have to share the password everytime.
Deploying files to hosted websites through ftp
Your cpanel should accept ftp or sftp. So you can create a username/password with access to your cpanel directory and create a workflow like the below to push to it. The below user action will push to ftp on every commit.
Here are the docs on the github action that gets used below https://github.com/SamKirkland/FTP-Deploy-Action
name: FTP Test
on:
push:
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: FTP-Deploy-Action
uses: SamKirkland/FTP-Deploy-Action@3.1.1
with:
ftp-server: ${{ secrets.SFTP_SERVER }}
ftp-username: ${{ secrets.FTP_USERNAME }}
ftp-password: ${{ secrets.FTP_PASSWORD }}
local-dir: toupload
Deploying to a git cpanel hosted repo
In this pipeline we are basically checking out the github code, and then changing the origin so that we can push code directly into CPANEL and commiting the code.
name: Push To CPanel Git
on:
push:
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Push to git repo
run: |
git remote set-url --add --push origin ssh://username@hostname/home/username/Project/example.git
git add .
git commit -m "Push to cPanel"
git push https://${{ secrets.GITHUB_TOKEN }}@domain.com/username/example.git -f
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.