3

I do a lot of web development and all of my static files (css, js, images) are hosted on AWS S3. Whenever I push out a change, I would like to take all of my changed static files and upload them to s3 automatically (so I don't have to do this manually).

The other issue is that if I upload them as the same name then I might run into caching issues e.g. user has old version of one JS file but new CSS, which could cause conflicts.

If the first is possible, is it also possible to change the names on those files and update the code with the new name? Obviously I would like this change to remain only on the servers while the code on my laptop wouldn't be renamed.

Jacob Kranz
  • 921
  • 3
  • 11
  • 24

2 Answers2

3

Look into git hooks - this will let you run a script after every push, so you can automate tasks exactly like you describe.

To avoid the caching issue is tricky, although I believe S3 uses Etags which should mitigate the problem somewhat.

Graham
  • 6,484
  • 2
  • 35
  • 39
0

Set up a git repo on S3. Set it up as push-only. Finally, set it to push to the S3 repository automatically. Hope this helps, do leave comments if you have further questions.

Community
  • 1
  • 1
hd1
  • 33,938
  • 5
  • 80
  • 91
  • I'm not looking to have my whole repo on s3; I just want to update my static files. So, as an example, I have all of the code and I push it to my server's repo. Let's say I've made one change to a css file. I'd like just that css file to be reuploaded to s3. Since I have a remote repo on my server, I don't want my whole repo on s3 as well... just the css change. – Jacob Kranz Jun 16 '13 at 18:59
  • Then branch it and [push only that branch](http://git-scm.com/book/en/Git-Basics-Working-with-Remotes‎) to S3. Add it as a [module to your working copy](http://git-scm.com/book/en/Git-Tools-Submodules). – hd1 Jun 16 '13 at 19:02