How to customize .cpanel.yml in this scenario?

jalil1408

Registered
Oct 23, 2019
3
1
1
Algeria
cPanel Access Level
Website Owner
/home/user/repository/ is a git repository, it is a Laravel directory that includes:
.git/
app/
public/
config/
routes/
datatbase
.cpanel.yml
server.php
....

and the root directory /home/user/ includes default cpanel folders plus the content of /home/user/repository/ except:
public_html/ instaed of public/ with the same content
no .git/ folder

how to customize .cpanel.yml to:
- copy all directories from /home/user/repository/ to /home/user/ except public/ and .git/
- copy the content of /home/user/repository/public/ to /home/user/public_html/
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,263
313
Houston

jalil1408

Registered
Oct 23, 2019
3
1
1
Algeria
cPanel Access Level
Website Owner
the documentation needs more details about the syntax used in `.cpanel.yml`, for example:

- can you use `/bin/rsync` instead of `/bin/cp`?
- can you use different name than `DEPLOYPATH`?
- what does `export` do? and can you use multiple `export` statements?
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,263
313
Houston
While I do definitely agree this could use more examples, I believe you can use any bash commands here.

You can read the man page about export from the CLI:

Code:
man export
Essentially though:

Set an environment variable. The supplied names are marked for automatic export to the environment of subsequently executed commands.
 

jalil1408

Registered
Oct 23, 2019
3
1
1
Algeria
cPanel Access Level
Website Owner
this works fine:

---
deployment:
tasks:
- export ROOT=/home/maahadonline/
- /bin/ls -A -I ".git" -I "public" | /bin/xargs -I % /bin/cp -ru % $ROOT
# print without copy : - /bin/ls -A -I ".git" -I "public" | /bin/xargs -t -I % /bin/cp -ru % $ROOT

- export PUBLIC=/home/maahadonline/public_html/
- /bin/ls -A -I ".htaccess" public | /bin/xargs -I % /bin/cp -ru public/% $PUBLIC
# print without copy : - /bin/ls -A -I ".htaccess" public | /bin/xargs -t -I % /bin/cp -ru public/% $PUBLIC
 
  • Like
Reactions: cPanelLauren