trilbymedia / grav-plugin-git-sync

Collaboratively Synchronize your Grav `user` folder hosted on GitHub, BitBucket or GitLab
Apache License 2.0
245 stars 57 forks source link

Best practices for use #5

Closed MerlinMason closed 7 years ago

MerlinMason commented 7 years ago

Hey guys, this looks really interesting and seems like the missing link to a solid workflow between Grav, GravAdmin, devs and clients.

However the current scoping to the user/pages directory doesn't quite seem to work right for my needs - I wanted to check if there's some best practices I'm not following?

To elaborate on my setup... I have my site version controlled locally on my machine, in GitHub and on Heroku. I'm working on theme changes locally and then backing them up on GitHub and deploying them to Heroku from my local machine with git push heroku master, and the client wants to make content changes on the server.

The issue is that for Heroku deployment, I need the whole site to be version controlled.

So maybe I have a few options...

  1. have two repos, one for the site and a git submodule for the user/pages directory
  2. have the main site gitignore the whole user folder and have git-sync control that, to created a nested repo (similar to how https://github.com/robwierzbowski/grunt-build-control works)
  3. setup git-sync to cover the whole codebase (except stuff like the cache)

Any tips?

Thanks!

MerlinMason commented 7 years ago

Update

I've been pursuing the idea of having the content as a separate repo and having the main codebase require it as a submodule... This works, except you have to install the git submodule into it's own directory, so you end up with a path like so:

user/my-submodule-directory/pages/01.home/default.md

w00fz commented 7 years ago

You don't need a submodule for this, you can keep all-in-one repository as a skeleton structure, ie the user folder is your skeleton, exactly like in the blog site skeleton.

Git Sync will only ever pull and push anything that is under pages and ignore everything else.

In the future we are planning to expand the pages only setting to other user directories such as themes, plugins, data, config, at the moment however, only pages work.

w00fz commented 7 years ago

Did this answer your question @MerlinBB ? Have you tried putting a full user folder on the git server and try to synchronize with it?

I know this is how @paulhibbitts has his hub course set up and it's working fine for him.

MerlinMason commented 7 years ago

Hmm to be honest I'm slightly confused, I was under the impression you can't nest git repositories? I don't really understand how I can version control my entire site and version control the pages folder at the same time... Clearly I'm missing something?!

paulhibbitts commented 7 years ago

Hi @MerlinBB , as @w00fz mentioned I've done something similar in the past by adding this into my top-level .gitignore file:

user/.git/ !user/.git/.

This way I was able to sync the entire Grav site via Github via GitHub Desktop even though I also had another repo within that folder. I hope that this is the type of info you were looking for.

w00fz commented 7 years ago

@MerlinBB yes you cannot nest git repositories but I'm confused as to why you need to do that. If your main repository is the user folder, then you can just use that with GitSync, you don't need to create a sub repository just for pages.

If your main repository is the whole grav instance, then my advice is to avoid that and just use the user folder as main repository. There really isn't anything that is worth having in the repository at Grav's core level, all that you should be concerned about is the user folder.

w00fz commented 7 years ago

Were these informations useful @MerlinBB ?

w00fz commented 7 years ago

I'm closing the issue but feel free to reopen or add to it if there's anything else

lpaulger commented 7 years ago

I'm running into the same sort of issue; each time I deploy grav I lose the git-sync configuration data and I lose all the pages in that heroku environment.

I've got users/ mapped correctly to the git-sync repo, locally and on the heroku instance; but it seems with each deployment to heroku, the pages content is wiped, and the git-sync configuration is missing. I have to manually add the config details and re-sync to get it working correctly.

What am I missing about the process here?

lpaulger commented 7 years ago

I'm thinking this plugin won't work for heroku installments because what heroku ends up running on the server does not include git.

I tried to setup the git-sync cmd to run as a post-install-cmd script

        "post-install-cmd": [
          "bin/plugin git-sync sync"
        ],

but encountered the following error:

> bin/plugin git-sync sync
remote:        
remote:        Synchronizing with https://github.com/<REPONAME>/grav-sync.git
remote:        
remote:                                                                                      
remote:          [RuntimeException]                                                          
remote:          fatal: Not a git repository (or any parent up to mount point /tmp)          
remote:          Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).  
remote:                                                                                      
remote:        

and then I investigated by connecting to the heroku app instance using heroku run bash and when I run the same command in the grav root directory I encounter the same issue, that git is missing. So I'm fairly certain this plugin isn't compatible with heroku deployments and I'm just looking for confirmation on that conclusion, if I am missing something that would be great to know as well. Thanks

@MerlinBB did you ever manage to solve your heroku deployment problem?

vesters commented 7 years ago

+1

1aurabrown commented 6 years ago

@lpaulger I have got this set up on heroku, and I see automatic commits coming in to the repo on github, so something seems to work, however I got the same error when trying to run the manual sync command on heroku. Anyone have ideas?

lpaulger commented 6 years ago

@1aurabrown no ideas, we ended up moving to aws for hosting our grav website becasue it uses git and doesn't restart automatically on a regular basis.

If you do manage to get the website working fully on heroku I would be super interested to hear what you did though 👍