I’m looking at ways to improve (or modernize) my workflow with regard to pushing changes to the remote server. Right now it’s the usual grind of edit a local file then SFTP to the remote. It works, it’s fine but I want to get more in the habit of tracking changes, hence Git. So I would like to incorporate it into the mix by first pushing the changes to Git (remote installation, obviously) which would then automatically deploy the changes to the site/remote files (I’m using a CMS).
My web host does not by default have Git installed so that’s the first step (assuming they’re willing to install it), but moving beyond that what else is required with regard to software or actual workflow to make the above scenario happen? I’ve used GitHub and Bitbucket and also have it installed locally so I have a grasp of Git basics.
Github has this notion of “hooks”, which are API calls that are automatically invoked whenever a new commit is pushed. You might want to investigate that. I am not sure what they would do in your case, but they are often used to trigger a blog post, or to trigger Jenkins (continuous integration test) to run the new code. There may be something in there that you could piggy-back on. I am not sure that your host would need to have Git on their server (many would refuse, citing security reasons, and they may be right) for this to work.
Walter
On Sep 1, 2013, at 1:21 AM, Todd wrote:
I’m looking at ways to improve (or modernize) my workflow with regard to pushing changes to the remote server. Right now it’s the usual grind of edit a local file then SFTP to the remote. It works, it’s fine but I want to get more in the habit of tracking changes, hence Git. So I would like to incorporate it into the mix by first pushing the changes to Git (remote installation, obviously) which would then automatically deploy the changes to the site/remote files (I’m using a CMS).
My web host does not by default have Git installed so that’s the first step (assuming they’re willing to install it), but moving beyond that what else is required with regard to software or actual workflow to make the above scenario happen? I’ve used GitHub and Bitbucket and also have it installed locally so I have a grasp of Git basics.
I often read about people using Git instead of (S)FTP for deployment (not any how-to descriptions, all pretty vague) and I always get the impression they have Git installed on their own server. But since you mentioned security issues I’m now wondering if these people are using private servers or are working in a much more complex or bespoke development environment where everything is managed on a very granular level.
I’ll look into the “hooks” aspect. I’m thinking if this isn’t a workflow you’re too familiar with (you would know better than I) then it may very well be beyond the scope of my abilities to successfully pull-off.
Todd
On Sep 1, 2013, at 11:37 AM, Walter Lee Davis email@hidden wrote:
Github has this notion of “hooks”, which are API calls that are automatically invoked whenever a new commit is pushed. You might want to investigate that. I am not sure what they would do in your case, but they are often used to trigger a blog post, or to trigger Jenkins (continuous integration test) to run the new code. There may be something in there that you could piggy-back on. I am not sure that your host would need to have Git on their server (many would refuse, citing security reasons, and they may be right) for this to work.
Walter
On Sep 1, 2013, at 1:21 AM, Todd wrote:
I’m looking at ways to improve (or modernize) my workflow with regard to pushing changes to the remote server. Right now it’s the usual grind of edit a local file then SFTP to the remote. It works, it’s fine but I want to get more in the habit of tracking changes, hence Git. So I would like to incorporate it into the mix by first pushing the changes to Git (remote installation, obviously) which would then automatically deploy the changes to the site/remote files (I’m using a CMS).
My web host does not by default have Git installed so that’s the first step (assuming they’re willing to install it), but moving beyond that what else is required with regard to software or actual workflow to make the above scenario happen? I’ve used GitHub and Bitbucket and also have it installed locally so I have a grasp of Git basics.
I’m finding a lot of examples of how to do what I want. There are more variations than I expected, many of which look surprisingly straightforward. And you’re right, hooks figure prominently into it. I feel fairly confident I can get one of them to work, assuming there aren’t any unusual hosting restrictions.
Todd
Github has this notion of “hooks”, which are API calls that are automatically invoked whenever a new commit is pushed. You might want to investigate that. I am not sure what they would do in your case, but they are often used to trigger a blog post, or to trigger Jenkins (continuous integration test) to run the new code. There may be something in there that you could piggy-back on. I am not sure that your host would need to have Git on their server (many would refuse, citing security reasons, and they may be right) for this to work.
Thanks Thomas, that one is new to me. I’ll have a look.
Last night I did find another tutorial of his http://css-tricks.com/video-screencasts/109-getting-off-ftp-and-onto-git-deployment-with-beanstalk/ which is yet another variation of the same concept. Part of my problem with some of these tutorials is that the server configuration they refer to are different than mine so I’m not sure where things need to go. I still haven’t gotten anything to work but I’m chipping away at it.
I now have a fully-functioning Git deployment workflow (all within Coda and using Bitbucket), no more SFTP. I looked at a lot of tuts but this is the one I managed to get (mostly) working http://www.blog.philiptutty.com/?p=67.
The only functionality I’m missing (which is the key reason I’m doing this at all) is getting the auto-update (git pull) to work. At the end of the above tut it says to place this,
I now have a fully-functioning Git deployment workflow (all within Coda and using Bitbucket), no more SFTP. I looked at a lot of tuts but this is the one I managed to get (mostly) working http://www.blog.philiptutty.com/?p=67.
The only functionality I’m missing (which is the key reason I’m doing this at all) is getting the auto-update (git pull) to work. At the end of the above tut it says to place this,
When you “shell out” from PHP, the shell that gets used is extremely limited, by design. You may need to put an absolutely root-relative path to git, and you may also need to see what directory it’s running from. You can put other commands in the “back-ticks” to get that kind of info. Try <?php echo( shell_exec('pwd') ); ?> (print working directory) to see where it is executing from, and also try which git to see if it can even find the git binary from that context. I don’t think the back-ticks automatically echo, so that’s why I’m using shell_exec inside an echo statement above.
Walter
*Note: If I manually type ‘git pull’ via SSH everything gets updated nicely.
So either I put the file in the wrong directory or there’s some else amiss.
‘pwd’ returned this: /home/myaccount/public_html
‘which git’ returned this: /usr/bin/git
This seems right.
Todd
On Sep 4, 2013, at 3:58 PM, Todd wrote:
I now have a fully-functioning Git deployment workflow (all within Coda and using Bitbucket), no more SFTP. I looked at a lot of tuts but this is the one I managed to get (mostly) working http://www.blog.philiptutty.com/?p=67.
The only functionality I’m missing (which is the key reason I’m doing this at all) is getting the auto-update (git pull) to work. At the end of the above tut it says to place this,
When you “shell out” from PHP, the shell that gets used is extremely limited, by design. You may need to put an absolutely root-relative path to git, and you may also need to see what directory it’s running from. You can put other commands in the “back-ticks” to get that kind of info. Try <?php echo( shell_exec('pwd') ); ?> (print working directory) to see where it is executing from, and also try which git to see if it can even find the git binary from that context. I don’t think the back-ticks automatically echo, so that’s why I’m using shell_exec inside an echo statement above.
Walter
*Note: If I manually type ‘git pull’ via SSH everything gets updated nicely.
So either I put the file in the wrong directory or there’s some else amiss.
I now have a fully-functioning Git deployment workflow (all within Coda and using Bitbucket), no more SFTP. I looked at a lot of tuts but this is the one I managed to get (mostly) working http://www.blog.philiptutty.com/?p=67.
The only functionality I’m missing (which is the key reason I’m doing this at all) is getting the auto-update (git pull) to work. At the end of the above tut it says to place this,
When you “shell out” from PHP, the shell that gets used is extremely limited, by design. You may need to put an absolutely root-relative path to git, and you may also need to see what directory it’s running from. You can put other commands in the “back-ticks” to get that kind of info. Try <?php echo( shell_exec('pwd') ); ?> (print working directory) to see where it is executing from, and also try which git to see if it can even find the git binary from that context. I don’t think the back-ticks automatically echo, so that’s why I’m using shell_exec inside an echo statement above.
Walter
*Note: If I manually type ‘git pull’ via SSH everything gets updated nicely.
So either I put the file in the wrong directory or there’s some else amiss.
I now have a fully-functioning Git deployment workflow (all within Coda and using Bitbucket), no more SFTP. I looked at a lot of tuts but this is the one I managed to get (mostly) working http://www.blog.philiptutty.com/?p=67.
The only functionality I’m missing (which is the key reason I’m doing this at all) is getting the auto-update (git pull) to work. At the end of the above tut it says to place this,
When you “shell out” from PHP, the shell that gets used is extremely limited, by design. You may need to put an absolutely root-relative path to git, and you may also need to see what directory it’s running from. You can put other commands in the “back-ticks” to get that kind of info. Try <?php echo( shell_exec('pwd') ); ?> (print working directory) to see where it is executing from, and also try which git to see if it can even find the git binary from that context. I don’t think the back-ticks automatically echo, so that’s why I’m using shell_exec inside an echo statement above.
Walter
*Note: If I manually type ‘git pull’ via SSH everything gets updated nicely.
So either I put the file in the wrong directory or there’s some else amiss.
Well, you wouldn’t necessarily, since you’re not logged in as root. You’re probably chrooted into your home folder when you log in as yourself. PHP runs as root, which is why it sees the whole directory structure.
Walter
On Sep 4, 2013, at 4:39 PM, Todd wrote:
It returns this: /usr/bin/git
Actually, now that I think about it I’m not sure where this is coming from, I don’t see any such structure on the remote server.
I now have a fully-functioning Git deployment workflow (all within Coda and using Bitbucket), no more SFTP. I looked at a lot of tuts but this is the one I managed to get (mostly) working http://www.blog.philiptutty.com/?p=67.
The only functionality I’m missing (which is the key reason I’m doing this at all) is getting the auto-update (git pull) to work. At the end of the above tut it says to place this,
When you “shell out” from PHP, the shell that gets used is extremely limited, by design. You may need to put an absolutely root-relative path to git, and you may also need to see what directory it’s running from. You can put other commands in the “back-ticks” to get that kind of info. Try <?php echo( shell_exec('pwd') ); ?> (print working directory) to see where it is executing from, and also try which git to see if it can even find the git binary from that context. I don’t think the back-ticks automatically echo, so that’s why I’m using shell_exec inside an echo statement above.
Walter
*Note: If I manually type ‘git pull’ via SSH everything gets updated nicely.
So either I put the file in the wrong directory or there’s some else amiss.
Well, I’m not able to get the auto-update to work which is unfortunate but I’m glad I got this far. However there’s a bigger a security problem with the .git folder being publicly accessible in the site root. I think other tuts skirted this issue in some clever way so I think I need to keep looking unless I can find a way to make it work without putting it in public_html.
It was fun while it lasted.
Todd
Well, you wouldn’t necessarily, since you’re not logged in as root. You’re probably chrooted into your home folder when you log in as yourself. PHP runs as root, which is why it sees the whole directory structure.
Walter
On Sep 4, 2013, at 4:39 PM, Todd wrote:
It returns this: /usr/bin/git
Actually, now that I think about it I’m not sure where this is coming from, I don’t see any such structure on the remote server.
I now have a fully-functioning Git deployment workflow (all within Coda and using Bitbucket), no more SFTP. I looked at a lot of tuts but this is the one I managed to get (mostly) working http://www.blog.philiptutty.com/?p=67.
The only functionality I’m missing (which is the key reason I’m doing this at all) is getting the auto-update (git pull) to work. At the end of the above tut it says to place this,
When you “shell out” from PHP, the shell that gets used is extremely limited, by design. You may need to put an absolutely root-relative path to git, and you may also need to see what directory it’s running from. You can put other commands in the “back-ticks” to get that kind of info. Try <?php echo( shell_exec('pwd') ); ?> (print working directory) to see where it is executing from, and also try which git to see if it can even find the git binary from that context. I don’t think the back-ticks automatically echo, so that’s why I’m using shell_exec inside an echo statement above.
Walter
*Note: If I manually type ‘git pull’ via SSH everything gets updated nicely.
So either I put the file in the wrong directory or there’s some else amiss.
<Directory \.git>
Order deny,allow
Deny from all
</Directory>
That’s untested, but it should get you started.
Walter
On Sep 4, 2013, at 5:36 PM, Todd wrote:
Makes sense.
Well, I’m not able to get the auto-update to work which is unfortunate but I’m glad I got this far. However there’s a bigger a security problem with the .git folder being publicly accessible in the site root. I think other tuts skirted this issue in some clever way so I think I need to keep looking unless I can find a way to make it work without putting it in public_html.
Well, you wouldn’t necessarily, since you’re not logged in as root. You’re probably chrooted into your home folder when you log in as yourself. PHP runs as root, which is why it sees the whole directory structure.
Walter
On Sep 4, 2013, at 4:39 PM, Todd wrote:
It returns this: /usr/bin/git
Actually, now that I think about it I’m not sure where this is coming from, I don’t see any such structure on the remote server.
I now have a fully-functioning Git deployment workflow (all within Coda and using Bitbucket), no more SFTP. I looked at a lot of tuts but this is the one I managed to get (mostly) working http://www.blog.philiptutty.com/?p=67.
The only functionality I’m missing (which is the key reason I’m doing this at all) is getting the auto-update (git pull) to work. At the end of the above tut it says to place this,
When you “shell out” from PHP, the shell that gets used is extremely limited, by design. You may need to put an absolutely root-relative path to git, and you may also need to see what directory it’s running from. You can put other commands in the “back-ticks” to get that kind of info. Try <?php echo( shell_exec('pwd') ); ?> (print working directory) to see where it is executing from, and also try which git to see if it can even find the git binary from that context. I don’t think the back-ticks automatically echo, so that’s why I’m using shell_exec inside an echo statement above.
Walter
*Note: If I manually type ‘git pull’ via SSH everything gets updated nicely.
So either I put the file in the wrong directory or there’s some else amiss.
I assume it’s in this section located at the bottom of the script,
$deploy = new Deploy('/var/www/foobar.com');
I used my site but no luck. Is it possible the ‘/var/www/’ part is different on my server? Could that be the problem? Not sure where else to look for problems.
Todd
You can htaccess the .git folder into oblivion.
<Directory .git>
Order deny,allow
Deny from all
That’s untested, but it should get you started.
Walter
On Sep 4, 2013, at 5:36 PM, Todd wrote:
Makes sense.
Well, I’m not able to get the auto-update to work which is unfortunate but I’m glad I got this far. However there’s a bigger a security problem with the .git folder being publicly accessible in the site root. I think other tuts skirted this issue in some clever way so I think I need to keep looking unless I can find a way to make it work without putting it in public_html.
Well, you wouldn’t necessarily, since you’re not logged in as root. You’re probably chrooted into your home folder when you log in as yourself. PHP runs as root, which is why it sees the whole directory structure.
Walter
On Sep 4, 2013, at 4:39 PM, Todd wrote:
It returns this: /usr/bin/git
Actually, now that I think about it I’m not sure where this is coming from, I don’t see any such structure on the remote server.
I now have a fully-functioning Git deployment workflow (all within Coda and using Bitbucket), no more SFTP. I looked at a lot of tuts but this is the one I managed to get (mostly) working http://www.blog.philiptutty.com/?p=67.
The only functionality I’m missing (which is the key reason I’m doing this at all) is getting the auto-update (git pull) to work. At the end of the above tut it says to place this,
When you “shell out” from PHP, the shell that gets used is extremely limited, by design. You may need to put an absolutely root-relative path to git, and you may also need to see what directory it’s running from. You can put other commands in the “back-ticks” to get that kind of info. Try <?php echo( shell_exec('pwd') ); ?> (print working directory) to see where it is executing from, and also try which git to see if it can even find the git binary from that context. I don’t think the back-ticks automatically echo, so that’s why I’m using shell_exec inside an echo statement above.
Walter
*Note: If I manually type ‘git pull’ via SSH everything gets updated nicely.
So either I put the file in the wrong directory or there’s some else amiss.
It’s most likely different. Every sysadmin has their own idea what to do in that respect. Back to your shell_exec script, look at what the pwd command returns. That would be the absolute path to your web root, beginning with a /.
Walter
On Sep 4, 2013, at 10:05 PM, Todd wrote:
I used my site but no luck. Is it possible the ‘/var/www/’ part is different on my server? Could that be the problem? Not sure where else to look for problems.
Interestingly that’s the path I tried without luck. This is very frustrating, I feel like I’m so close but still overlooking the obvious. It makes me want to stop shaving my head and grow my hair back just so I can pull it all out.
Todd
It’s most likely different. Every sysadmin has their own idea what to do in that respect. Back to your shell_exec script, look at what the pwd command returns. That would be the absolute path to your web root, beginning with a /.
Since you have ssh to this box, what do you see when you are cd’d into that folder and type pwd in your shell? If that’s different than what you get from PHP, try that instead.
Walter
On Sep 4, 2013, at 10:34 PM, Todd wrote:
Interestingly that’s the path I tried without luck. This is very frustrating, I feel like I’m so close but still overlooking the obvious. It makes me want to stop shaving my head and grow my hair back just so I can pull it all out.
It’s most likely different. Every sysadmin has their own idea what to do in that respect. Back to your shell_exec script, look at what the pwd command returns. That would be the absolute path to your web root, beginning with a /.
cd into /public_html/ yields the same path. Maybe there’s another setting in the script that’s causing a problem. It’s nutty.
Todd
Since you have ssh to this box, what do you see when you are cd’d into that folder and type pwd in your shell? If that’s different than what you get from PHP, try that instead.
Since you have ssh to this box, what do you see when you are cd’d into that folder and type pwd in your shell? If that’s different than what you get from PHP, try that instead.