Skip to content

Clone Git Repository to Create and Auto-Update Site

  • Taking GitHub as an example, how to clone Git repository in aaPanel to create website, and setup Webhook to achieve automatic synchronization and updates of the website when the repository is updated.

Clone Repository and Create Website

  1. Copy SSH Key from aaPanel and add it to GitHub

    Website --> Add site --> Create for Git

    alt text

  2. Log in to GitHub and add the SSH Key

    Profile Photo --> Settings --> SSH and GPG keys --> New SSH key

    alt text
    alt text

    • Enter a Title and paste the SSH key copied from aaPanel into the Key field.
  3. Create new repository or select an existing one

  4. Copy the repository URL; you can choose either HTTPS or SSH for cloning

    • Note down the branch you need, as you will have to enter the correct branch when creating the website later.
      alt text
  5. Create website in aaPanel and clone repository

    Website --> Add site --> Create for Git

    • Enter your domain and select the PHP version.

    • Site directory (e.g., /www/wwwroot/your_site). Note that this directory must be empty.

    • Paste the repository URL (e.g., https://github.com/username/repository.git or [email protected]:username/repository.git).

    • Enter the branch (e.g., main).
      alt text

    • After confirmation, the website will be created automatically and the repository will be cloned.

    • Tip: If an error occurs during cloning, troubleshoot based on the on-screen prompts (e.g., incorrect SSH Key configuration, invalid repository URL, invalid branch, network connection issues, etc.).

Automatic Website Updates

  • When the repository is updated, configure Webhook to trigger the execution of specified script. This will automatically sync the latest code from the repository to the website directory, enabling automatic website updates.

Use Create for Git by default install the Webhook plugin in then App Store

Your_site --> Conf --> Git Manager

  1. In aaPanel, find the Git website, click Conf to access Git Manager, then go to Script to add script

    Git Manager --> Script

    • Enter an alias for the Script. Use the default Deploy Script.
      alt text
  2. Associate the Webhook with the Script in the Repository

    Git Manager --> Repository

    • Select the Script added earlier and click Save.

    alt text

  3. Copy the Webhook URL

    Git Manager --> Repository

    alt text

  4. Add the Webhook in the Settings of your Git repository
    alt text

    • Payload URL: Paste the Webhook URL copied earlier.

    • Content type: Select application/json

    • SSL verification: Select Disable

    alt text

  5. After adding the Webhook, test the automatic update function of the Webhook

    • Modify file and commit it to the Git repository; this will trigger the Webhook to execute the specified Script.

    • Successful trigger:
      alt text

    • Script execution result:
      alt text

    • Tip: If the website content is not updated, check the Webhook Logs in aaPanel’s Git Manager or view Recent deliveries on the Webhooks page of your Git repository. Troubleshoot based on the log information (e.g., failed Webhook request, script execution error, etc.).