0

I am trying to accomplish the auto deploy of project to my shared hosting server.

What i am trying to accomplish is that the public directory needs to be checked out in the www directory, where as the other files and directories needs to checkout on the directory under root e-g /home/{username}/laravel-project-files

I see there is a "Sparse Checkout" option in git.

but i need to checkout to two different work directories with two different sets of files.

public will go to the /home/{username}/public_html/ where as remaining laravel project files will go under /home/{username}/laravel-project-files

I am just a GUI user of git, but hopefully there might be a solution or any other better way to handle this.

i am using github webhooks to auto deploy the project to my hosting server.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Sizzling Code
  • 5,932
  • 18
  • 81
  • 138
  • 1
    Wouldn't be the easiest to put everything in `/home/{username}/laravel-project-files` and then make a symlink at `/home/{username}/public_html/` that points to `/home/{username}/laravel-project-files/public`? – Vampire May 31 '17 at 22:23
  • @Vampire i didnt thought of that. you are genius. But how to do symlinks through the ssh on cpanel?? – Sizzling Code May 31 '17 at 22:28
  • 1
    1.Initialize the two directories as git repositories. Do sparse-checkout twice. Or, 2. Copy specific files where they are needed. – ElpieKay Jun 01 '17 at 03:10
  • What is different between normal SSH and SSH through cpanel? – Vampire Jun 01 '17 at 06:34
  • @Vampire I followed your way. and its working fine.. Actually i am trying this on shared hosting cpanel. a2hosting. they give access to git and ssh. so we can install laravel application easily and have access to composer commands as well. – Sizzling Code Jun 02 '17 at 12:46
  • @Vampire As i followed your advice and did a symbolic link, but there is one issue here. when new file has been created in that directory then that new file is not automatically shown to the target directory. i will have to make a symbolic link back again to make it work :( rest seems ok. here is how i made a symbolic link `ln -s /path/to/{laravelProject}/public/* /home/{username}/public_html/` working fine but when new file has been introduced in public directory then that file is not auto synced to the public_html directory. – Sizzling Code Jun 02 '17 at 12:50
  • @ElpieKay Yes you are right. this can also be a way. but then i will have to make two webhooks, two repositories and will be doing two different git checkouts for a single project. So if i have one more laravel project, i will have to have 4 repositories and so on. Works but dosen't seem right to me. However symbolic link way seemed a better way by vampire but it also has a flaw that needs to be looked over. – Sizzling Code Jun 02 '17 at 12:53
  • @SizzlingCode whichever solution you take, I think all the jobs can be done by some scripts automatically. – ElpieKay Jun 02 '17 at 13:03
  • 1
    You did **not** make one symbolic link how I advised. You made `n` symbolic links, `n` being the amount of files in `public`. With this (one symlink per file) you of course do not get new files in public_html. Instead you have to make the folder `public_html` a symlink to `public` like with `rm -rf /home/{username}/public_html/ && ln -s /path/to/{laravelProject}/public /home/{username}/public_html`. – Vampire Jun 02 '17 at 13:09
  • @Vampire Thanks for Solution, i will try this. Your Solution Helped in alot <3 – Sizzling Code Jun 10 '17 at 18:10

1 Answers1

2

Simply put everything in /home/{username}/laravel-project-files and then make a symlink at /home/{username}/public_html/ that points to /home/{username}/laravel-project-files/public with something like rm -rf /home/{username}/public_html/ && ln -s /path/to/{laravelProject}/public /home/{username}/public_html.

Vampire
  • 35,631
  • 4
  • 76
  • 102