Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Is there a way to automatically pull from GitHub?

Discussion in 'General Discussion' started by angelleye, Jul 4, 2018.

  1. angelleye

    angelleye Active Member

    Joined:
    Nov 25, 2011
    Messages:
    35
    Likes Received:
    1
    Trophy Points:
    58
    Location:
    Kansas City, MO
    cPanel Access Level:
    Root Administrator
    Twitter:
    I just recently discovered that Git Version Control is available in cPanel and makes it extremely quick and easy to clone GitHub repos into a directory on the server. This is awesome!

    The one thing I'm missing is the ability to automatically pull from GitHub any time changes are made there. Right now I have to do that manually.

    Is there any way to setup webhooks with GitHub through cPanel so that changes on GitHub will be automatically pulled into the cPanel repo?

    Any information on this would be greatly appreciated. Thanks!
     
    Tarak Nath likes this.
  2. cPanelLauren

    cPanelLauren Forums Analyst II
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    3,530
    Likes Received:
    253
    Trophy Points:
    193
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. angelleye

    angelleye Active Member

    Joined:
    Nov 25, 2011
    Messages:
    35
    Likes Received:
    1
    Trophy Points:
    58
    Location:
    Kansas City, MO
    cPanel Access Level:
    Root Administrator
    Twitter:
    It says this...

    So this seems to be a guide on pushing these repos out to other repos, but what I'm looking is automated pulling of a remote repo (GitHub) into this one.

    All I need is for exactly what happens when I manually push the "Update" button to happen automatically.
     
  4. cPanelLauren

    cPanelLauren Forums Analyst II
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    3,530
    Likes Received:
    253
    Trophy Points:
    193
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. angelleye

    angelleye Active Member

    Joined:
    Nov 25, 2011
    Messages:
    35
    Likes Received:
    1
    Trophy Points:
    58
    Location:
    Kansas City, MO
    cPanel Access Level:
    Root Administrator
    Twitter:
    Yeah, I found this: github.com/olipo186/Git-Auto-Deploy

    We should be able to make it happen this way, but it would sure be a nice feature to have built in. It's so close right now! :)

    Does that Update button inside each of the Git repos trigger a particular script that I could hook up to a CRON job?
     
    #5 angelleye, Jul 7, 2018
    Last edited by a moderator: Jul 7, 2018
  6. cPanelLauren

    cPanelLauren Forums Analyst II
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    3,530
    Likes Received:
    253
    Trophy Points:
    193
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hi @angelleye

    After speaking with the Product Owner for that team I believe that the specific API function that is being triggered is UAPI Functions - VersionControl::update - Developer Documentation - cPanel Documentation which you should be able to add to a script in for a cron to do what you want.

    I also want to encourage you to open a feature request on this, we did have the feature request here Allow users to install websites from version control which included webhooks originally:

    The comments from cPanelAdamF are super informative on the plan for this in the future as well but if you want to see the functionality in the product we strongly advise a feature request. If you do end up opening it please post the link here so others can vote on it as well.


    Thanks!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. cPanelAdamF

    cPanelAdamF cPanel Product Owner
    Staff Member

    Joined:
    Mar 21, 2013
    Messages:
    238
    Likes Received:
    52
    Trophy Points:
    103
    Location:
    Houston TX
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    I'll add an important thing to @cPanelLauren's reply: Sending the branch parameter to that Update API call will cause a git pull to occur in order to ensure that it's got the latest from your remote. This is new behavior as of v74.

    ...and I'll definitely echo @cPanelLauren's guidance to engage with us on a feature request for official webhook support. We were not able to get it done for v74 so we shipped without it. The product management team inside cPanel pays very close attention to that feature request site!
     
    fidividi and cPanelLauren like this.
  8. Gojko

    Gojko Well-Known Member

    Joined:
    Nov 24, 2014
    Messages:
    82
    Likes Received:
    7
    Trophy Points:
    8
    Location:
    Macedonia
    cPanel Access Level:
    Root Administrator
    Hello, i'm looking how to make this one.
    So tried to run cron job:
    Code:
    /usr/bin/uapi VersionControl update name=test repository_root=/home/user/public_html/test branch=master source_repository='{"remote_name":"origin"}'
    and i got:

    Code:
    ---
    apiversion: 3
    func: update
    module: VersionControl
    result:
      data:
        available_branches:
          - master
        branch: master
        clone_urls:
          read_only: []
    
          read_write: []
    
        deployable: 0
        last_deployment: ~
        last_update:
          author: author <111+user@users.noreply.github.com>
          date: '1540507571'
          identifier: e6175a616d542c6acf4bce690b7f772911ccb2
          message: Create fff.txt
        name: test
        repository_root: /home/user/public_html/test
        source_repository:
          remote_name: origin
          url: https://github.com/user/test.git
        tasks: []
    
        type: git
      errors: ~
      messages: ~
      metadata: {}
    
      status: 1
      warnings: ~
    i get the same thing if i use php, cURL login to php and run session url from : UAPI Functions - VersionControl::update - Developer Documentation - cPanel Documentation

    response:
    Code:
    {
        "status":1,
        "messages":null,
        "errors":null,
        "metadata":{},
        "data":{
             "source_repository":  
                 {"remote_name":
                 
                 "origin",
                  "url":"https://github.com/user/test.git"
                 },
                "deployable":0,
                "name":"test",
                "repository_root":"/home/wuser/public_html/test",
                 "available_branches":["master"],
                 "clone_urls":
                                {
                                 "read_only":[],
                                  "read_write":[]
                                 },
                 "branch":"master",
                 "tasks":[],
                   "last_update":
                             {
                             "date":"111111",
                             "author":"user <15720022+user@users.noreply.github.com>",
                             "message":"Create fff.txt",
                             "identifier":"e6175a616d542c6acf4bce690b7f77291d41c2"
                              },
                  "type":"git",
                  "last_deployment":null
           },
           "warnings":null
    }
     
  9. cPanelAdamF

    cPanelAdamF cPanel Product Owner
    Staff Member

    Joined:
    Mar 21, 2013
    Messages:
    238
    Likes Received:
    52
    Trophy Points:
    103
    Location:
    Houston TX
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    A question for you before I ask more diagnostic questions:

    I see "https://github.com/user/test.git" and "/home/user/public_html/test" as values in the result from your API calls. The github address specifically 404's when I attempt to load it. Can I assume that you've "greeked" these values for privacy reasons and you're not using that as actual values?

    The first thing I wanted to check was that the repository the system is attempting to pull from actually exists first before we go too far down other paths of investigation.
     
  10. Gojko

    Gojko Well-Known Member

    Joined:
    Nov 24, 2014
    Messages:
    82
    Likes Received:
    7
    Trophy Points:
    8
    Location:
    Macedonia
    cPanel Access Level:
    Root Administrator
    Yes, and worked ok trough cPanel Git Version Control Option.
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice