Skip to content

Commit

Permalink
changed to use deploy path from webhook payloads repo name and updated
Browse files Browse the repository at this point in the history
documentation.
  • Loading branch information
maks committed Dec 6, 2011
1 parent 33a2d07 commit 9a8edb3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
24 changes: 23 additions & 1 deletion README.textile
Expand Up @@ -2,6 +2,28 @@ h1. A simple continuous deploy server for github projects

h2. Author: Maksim Lin

h2. Usage

This is a very simple continous deploy server that listens on a port for POSTs from
githubs post-receive webhook.

The server will cwd into the project folder. This fodler is expected to be a git working copy
where it will execute "git pull origin master && npm install".

Note that the server will only run if it gets a payload that specifies a push tp the master branch,
ie. refs/heads/master


h3. Configuration

Configuration is via environment variables:

PORT - port to listen on
RESTART_CMD - the shell command to execute
DEPLOY_PATH - the path to append the project name to that becomes the cwd prior to pulling from the gitrepo

Please set the bin/run.sh as an example.

h2. License

Copyright 2011 Maksim Lin
Expand All @@ -19,4 +41,4 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Mydvds. If not, see <http://www.gnu.org/licenses/>.
along with node-github-deployhook. If not, see <http://www.gnu.org/licenses/>.
2 changes: 1 addition & 1 deletion bin/run.sh
@@ -1,6 +1,6 @@
#! //bin/sh
export PORT=1974
export DEPLY_PATH=/var/www/mydvds/app
export DEPLY_PATH=/var/www
export RESTART_CMD="sudo restart mydvds"

cd /var/www/node-github-deployhook
Expand Down
11 changes: 5 additions & 6 deletions lib/server.js
Expand Up @@ -8,15 +8,13 @@

var log = require('nlogger').logger(module),
http = require('http'),
path = require('path'),
decodeForm = require('./www-forms').decodeForm,
exec = require('child_process').exec,
command = 'git pull origin master && npm install',
currentResponse,
reqBody = [],
options = {
cwd: process.env.DEPLOY_PATH
};

options = {};

/**
* @param {bool} processedOk
Expand All @@ -35,9 +33,10 @@ function sendResponse(processedOk, messageText) {

//execute a git pull within the deployPath
//and then execute an npm install
function deploy() {
function deploy(projectName) {

log.info('doing pull and npm');
options.cwd = path.join(process.env.DEPLOY_PATH, projectName);
exec(command, options, function(error, stdout, stderr) {
if (error) {
return log.error(command, {
Expand Down Expand Up @@ -93,7 +92,7 @@ function requestHandler(request, response) {
log.info('repo:'+data.repository.name);
log.info('ref:'+data.ref);
if (data && data.ref && (data.ref === 'refs/heads/master')) {
deploy();
deploy(data.repository.name);
}
});
}
Expand Down

0 comments on commit 9a8edb3

Please sign in to comment.