5
votes

Is it possible to sync a GitHub repository with a google cloud storage bucket, so that I can edit the repository on GitHub and it automatically updates the bucket with the changes. I have already tried the google cloud platform source code tools, but I couldn't find any way to update my bucket based on the source code.

Thanks

2
I have already checked this, as far as I can tell all it does is include the source code in my google cloud platform console. I want it to add/remove/change files in my bucket when I change them in my repository.Alex

2 Answers

7
votes

There's no direct way to synchronize between a git repo and GCS. However, if you can tolerate some delay between when you update GitHub and when the changes show up in your bucket, you could create a Google Compute Engine instance and clone your git repo to the local file system there, and then set up a cron job on that instance that periodically does a git pull from your GitHub repo and then runs gsutil rsync to update your GCS bucket from there. Make sure to exclude the .git files from the rsync command, for example by running a command like:

gsutil rsync -rd -x \.git . gs://your-bucket
2
votes

You can use git annex with GCS. The last time I tried it was 2013, but it worked flawlessly then. You can see my example of how to use Google Cloud Storage with git-annex.