Deleting files in public_html via .cpanel.yml before deploying from repo

Bart Kipping

Registered
Jan 13, 2021
2
0
1
The Netherlands
cPanel Access Level
Root Administrator
Hi there,

I deploy files from my repo to the public_html folder via the .cpanel.yml file, this works great.

BUT...

I want to delete the files that are already in public_html because i don't want the different versions to overlap.

Tried this, it deletes the files but then failes at copying the new ones:

Code:
---
deployment:
  tasks:
    - export DEPLOYPATH=/home/<username>/public_html/
    - cd ../../public_html
    - rm -r *
    - mkdir test

    - cd ../repositories/cprepo
    - cp README.md $DEPLOYPATH
Could anyone tell me why this won't work and possibly suggest a solution?

Thanks in advance,

Bart
 
Last edited by a moderator:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
3,098
389
243
cPanel Access Level
Root Administrator
Hey there! I know you've already specified the path in a previous command, but seeing a wildcard with the "rm" command still scares me a bit. It would be best to use full paths instead of the "cd ../../" and for the rm as well - can you try that and see if that works?