How can I use post-commit hooks to copy committed files to a web directory from SVN?

后端 未结 3 767
长情又很酷
长情又很酷 2021-01-11 18:00

My Ubuntu server has Apache and Subversion installed. I use this server as a staging server, purely for testing purposes. I use Apache to host the web application, and Subve

相关标签:
3条回答
  • 2021-01-11 18:50

    It can be done, but automatically pushing every commit to the production website isn't always a good idea. Sometimes there are other changes that need to go along, and breaking the site because the new code is there, but the database schema hasn't been updated yet is just embarrassing.

    What I tend to do instead is make the server checkout a copy of svn, then, once I'm ready with everything else that has to happen, I do an svn update on it.

    But if you really wanted, you can put commands in the post-commit trigger, that will do everything automatically for you. This could include running a migration script on the server (if one exists for this change), to take care of any non-code changes that need to happen.

    0 讨论(0)
  • 2021-01-11 19:00

    I think the real, overarching question you should be asking yourself---which you may already have asked yourself of course---is this: "how can I test my code most easily before deploying it?"

    I think a good answer is to install Apache on your development box and run it as your own user, with webroot and/or cgi path at /home/richardhenry/src/mywebsite (or whereever you check out your code).

    That way, you can test your code without even committing. As a result, you won't litter your trunk with broken or useless commits. In general, keeping independent things independent tends to be A Good Idea (TM).

    Alternatively, sync the web server against your working directory with rsync, or write a script which pushes your file(s) from the dev box to your staging server and add a Makefile rule which runs your script (or calls up rsync). If you want to be really fancy, use inotify or some other file notification monitor to run your script automatically.

    0 讨论(0)
  • 2021-01-11 19:02

    The "official" answer is here.

    I'm managing a website in my repository. How can I make the live site automatically update after every commit?

    0 讨论(0)
提交回复
热议问题