1

8I am trying to update my cpanel through Github repositories.

Let me explain what I tried :

Step 1: At First, I created a Private Repository in Github
Step 2: Cloned the repositories in my local computer
Step 3: added all the files pushed in GitHub Repository ( Successfully uploaded with the commit message"
Step 4 : created a .cpanel.yml inside project folder.
.cpanel.yml code below

---
deployment:
  tasks:
    - export DEPLOYPATH=/home/cpanelUserName/public_html
    - /bin/cp * $DEPLOYPATH
    - /bin/cp/ -r * $DEPLOYPATH
    - /bin/chmod 755 ${DEPLOYPATH}
    - /bin/find ${DEPLOYPATH} -type d -exec /bin/chmod 755 '{}' \;
    - /bin/find ${DEPLOYPATH} -type f -exec /bin/chmod 644 '{}' \;

Step 5: Pushed in Github repository ( Successfully added)

Now i logged in inside my cpanel. Clicked on Git Version Control.

Created a Repository

Repository image below : Cpanel repository information ss

Step 6: I created a private key through ssh from the Cpanel ssh panel. And added in Github Repository Deploy key.

Step 7 : I just added the cpanel repository ssh url with my github repository using this command

git remote add server ssh://myUserName@domain.com:21098/home/myUserName/repositories/myportfolio 

Step 8: I changed the web.php file & added it to the GitHub repository. (Successfully) Step 9: I tried to upload the changes to Cpanel through this command

git push server

#Note: asked for Cpanel password. When the password is valid it's uploading the changes inside repositories/myportfolio directory.

Repositories/myportfolio directory inside /home/myUsername directory. I mean outside of the public_html directory.

I can able to change the repository folder. But, .cpanel.yml file not working properly.

What to do now?

Ripon Uddin
  • 709
  • 3
  • 14
  • 29

1 Answers1

0

.cpanel.yml runs when server clones a repository and try to deploy after fetching new update.

You are pushing your repository from your computer.

You should use post-receive hook instead.

  • 1
    Not sure what you mean there, can you be a bit more specific? You're saying it will only work if the push comes from GitHub or something? cPanel should have set up the hooks, are you saying they aren't set up correctly and we need to set them up manually? – Shawn Jun 26 '21 at 17:40
  • post-receive hook runs after receiving an update. If someone pushes their local repo to web server's repository. It will execute post-receive hook. – Hazzaz Bin Faiz Jul 09 '21 at 00:23
  • 1
    Basically, the cPanel deployment I was provided had errors in the post-receive hook responsible for this, I had to fix the hook for things to work as expected. The broken hook was provided by A2Hosting, in case this can help anyone else. – Shawn Mar 05 '22 at 20:03