AKZN Notes

Archives for My Lazy and Forgetful Mind

Deploy from GitHub to cPanel Using Webhook and Deployment Hook (No SSH Key)

Step 1: Set Up Git Version Control in cPanel:

  1. Log in to your cPanel account.
  2. Navigate to the "Git Version Control" section (or similar) and create a new repository or choose an existing one.
  3. Note down the repository URL provided by cPanel. This URL is used to push changes.

Step 2: Configure GitHub Webhook:

  1. In your GitHub repository, go to "Settings" > "Webhooks" > "Add webhook."
  2. In the "Payload URL" field, enter the cPanel repository URL.
  3. Set "Content type" to "application/json."
  4. In the "Secret" field, enter the secret token you generated earlier in cPanel.
  5. Select "Just the push event" or other relevant events to trigger the webhook.
  6. Save the webhook.

Step 3: Set Up cPanel Deployment Hooks:

  1. In cPanel, under the "Git Version Control" section, find the "Deployment Hooks" or similar option.
  2. Set up a deployment hook to specify the branch you want to deploy and the action to perform on push. This action could be "Deploy the contents of the repository to the desired directory."

Step 4: Test the Setup:

  1. Make a change to your GitHub repository and push it.
  2. GitHub will trigger the webhook, sending a payload to cPanel.
  3. The cPanel Deployment Hook will be executed automatically, deploying the changes to the desired directory.

This approach leverages cPanel's built-in features for automated deployment, without requiring you to create a separate deployment script.

Leave a Reply

Your email address will not be published.