Deploy to cPanel through GitHub Actions.
To deploy your code to cPanel using GitHub Actions, follow these steps:
-
Create a workflow file (e.g.,
.github/workflows/cpanel-deployment.yml
) in your repository. -
Add the following content to the workflow file:
name: cPanel Deployment
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy to cPanel
id: deploy
uses: paxha/cpanel-deploy@v4
with:
host: 'https://serverxxx.web-hosting.com'
port: '2083' # Optional. Don't change it unless you know what you're doing
username: 'your-username' # Your cPanel username
api_token: '${{ secrets.CPANEL_API_TOKEN }}' # Your cPanel API Token generated by above user.
remote_path: '/home/your_username/repositories/your_repository'
branch: main # Optional e.g 'main' or 'master'
deploy: false # Optional e.g true or false. If you don't have .cpanel.yml file or If you don't want to run this file.
- name: echo deploy-duration
run: echo "Deployment took ${{ steps.deploy.outputs.duration }} milliseconds"