Help on YML File for Contineous Deployment from GitHub

Dec 9, 2020
5
0
1
G3 Block, Royal Plaza
cPanel Access Level
Website Owner
Hi Experts,

I am trying to Deploy website from GitHub to CPanel. I have 2 folder: 'documentation' and 'website' in GitHub. I can deploy both folder to 'public_html' using 'Git Version Control' in Cpanel. But my requirement is I would like to move the files inside the 'website' folder to root of 'publc_html' and i don't want to pull 'documentation' folder to 'public_html'. I tried the following code. But my files inside 'website' folder is moving to 'public_html' only for first time of deployment and it is not working when i create new files and try to deployment. And also i need to avoid the 'documentation' folder on deployment. So please advice me whats wrong with my code. Awaiting for anyone's help on this as i am wasting days for this. Thanks in advance!
---
deployment:
tasks:
- export DEPLOYPATH=/home/igmengct/public_html/
- /bin/cp website/* $DEPLOYPATH
- /bin/cp miscellanious/* $DEPLOYPATH
 
Last edited by a moderator:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
3,193
400
243
cPanel Access Level
Root Administrator
Hey there! It may be easiest to create a .gitignore file to exclude the "documentation" directory completely. From the output though, it seems like you're trying to make some changes in Bash directly, which wouldn't be related to Git. From what you've described, I'm not completely sure what issue you're having as the commands you have provided would work well in Bash, but wouldn't be related to your Git Version Control tools.

Are you just wanting the content of /home/igmengct/public_html/website to be placed in /home/igmengct/public_html/ ? If so, that isn't something that would be handled through Git itself, but by managing the files on the account outside of Git or changing how you deploy them.

If you're trying to deploy an entire directory, you may find the following guide helpful:

 
Last edited:
Dec 9, 2020
5
0
1
G3 Block, Royal Plaza
cPanel Access Level
Website Owner
Hi cPRex,

Thank You for your Reply. I read your valuable message and i thought that my explanation can be improve to make a good understanding to you.
Following is the another explanation of my requirement. Just look it.

Following is my project folder structure
+------------------------------------------------------------------------------------------------------+
My Project Folder (git is in the root)
+------------------------------------------------------------------------------------------------------+
- documentation (folder)
analysis.doc
- website (folder)
index.html
+------------------------------------------------------------------------------------------------------+

I use following Git Bash Command and it is successfully done!
git push origin master

+------------------------------------------------------------------------------------------------------+
(GitHub) Repository (i got same structure as my local machine)
+------------------------------------------------------------------------------------------------------+
- documentation (folder)
analysis.doc
- website (folder)
index.html
+------------------------------------------------------------------------------------------------------+
Up to here things are okay as per my plan.

Now i logon to CPanel and configured 'Git Version Control' to deploy from GitHub to CPanel's 'public_html' folder.
I able to do it successfully and i getting the same repository structure in 'public_html'

But my requirement is, I don't need full repository files to 'public_html'.
I just need only the 'index.html' from 'website' folder to the root of 'public_html'.
When i refer more, i able to know about 'YML' file, and i thought that it will do my requirement as per it's code structure.
But unfortunately i got few of confusions with the documentation and i wasted so many days for this. At last i tried the following code in .cpanel.yml

---
deployment:
tasks:
- export DEPLOYPATH=/home/igmengct/public_html/
- /bin/cp -R website $DEPLOYPATH

The above code is worked first time and i was so happy. But when I do a second deploy with adding a new page, it is not working.
And also i getting a blue highlighted alert (' The system cannot deploy ') in the deploy area and I did'nt understand whats wrong with me.

I need continues deployment and Following is the structure i would like to get when i deploy to CPanel's 'public_html' folder.
+------------------------------------------------------------------------------------------------------+
(CPanel) public_html
+------------------------------------------------------------------------------------------------------+
index.html
+------------------------------------------------------------------------------------------------------+
Is my requirement is possible?. If it is possible, my entire website design will run in an automated process.
It will be an amazing help if you can do it for me. Thanks in Advance!
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
3,193
400
243
cPanel Access Level
Root Administrator
Thanks for the additional details. In regards to your first, post, maybe if you tried doing something like this:

Code:
deployment:
tasks:
- export DEPLOYPATH=/home/igmengct/public_html/
- /bin/cp website/* $DEPLOYPATH
- /bin/cp miscellanious/* $DEPLOYPATH
- /bin/rm -rf $DEPLOYPATH/documentation
or this

Code:
deployment:
tasks:
- export DEPLOYPATH=/home/igmengct/public_html/
-- export PROJECTROOT=/home/igmengct/repositories/project_name
- /bin/cp $PROJECTROOT/website/* $DEPLOYPATH
- /bin/cp $PROJECTROOT/miscellanious/* $DEPLOYPATH
that would give you a better result? You'll just want to be careful on the paths you use there, but I don't believe there is going to be a way to fully automate this with just Git tools.
 
Dec 9, 2020
5
0
1
G3 Block, Royal Plaza
cPanel Access Level
Website Owner
Hi CPRex,

Thanks for the Reply. Unfortunately it is not worked. My target is to get all the files inside the 'website' folder to the root of 'public_html' in each deployment.
I hope you can find where is my mistake from the following screenshot: Thanks
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
3,193
400
243
cPanel Access Level
Root Administrator
I'm sorry to hear that still isn't working well for you. If you have /home/username/public_html and you are deploying the "website" directory to /home/username/public_html/website, I would expect the "/bin/cp website/* $DEPLOYPATH" command to work well for you.

If that isn't working, but you're able to deploy the /home/username/public_html/website directory as expected, maybe it would be easier to change the primary document root of the domain to that directory instead so no additional commands are necessary to get things working?
 
Dec 9, 2020
5
0
1
G3 Block, Royal Plaza
cPanel Access Level
Website Owner
Hi CPRex,

Sorry to know that you are still not understood my point because of my bad English
Please understand that I need the following point (a) Not at all (b).
a) (This is I need) /home/igmengct/public_html/index.html
b) (Not this) /home/igmengct/public_html/website/index.html
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
3,193
400
243
cPanel Access Level
Root Administrator
@shaijuelayidath - I do see what you are trying to do, but I'm just not sure why it isn't working with the commands you've mentioned. My solution of changing the document root to /home/igmengct/public_html/website/ would eliminate the need for any additional commands, but it's up to you with how you want to handle that. It seems that something isn't working with the command portion of the deployment at this point.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
3,193
400
243
cPanel Access Level
Root Administrator
That error does seem to indicate there is an issue with the key. Since you've had a few issues with this git deployment it might be best if you spoke with the hosting provider to see if there is an underlying problem that may be related to your copy commands and the interface problem you're now experiencing.