Esempio n. 1
0
#!/usr/bin/env node

var hookshot = require("hookshot");
var program  = require("commander");

program
  .option("-b, --branch <branch>", "Git branch to use when waiting for posthooks")
  .option("-c, --command <command>", "Command to run after posthook.")
  .option("-p, --port <number>", "Port in which to watch for postcommit web hooks.")
  .parse(process.argv);

if (!program.branch || !program.command || !program.port) {
  console.error("--branch, --command, and --port are all required.")
  program.outputHelp();
  process.exit(1);
}

hookshot("refs/heads/" + program.branch, program.command).listen(program.port, function() {
  console.log("Huzzah! Listening on port " + program.port + " for push events on " + program.branch + ".")
});
var hookshot = require('hookshot');
hookshot('refs/heads/dist', 'git fetch origin master && git checkout origin/master -f && ./scripts/continuous-deployment.sh').listen(3000);
var hookshot = require('hookshot');
hookshot('refs/heads/master', 'git fetch origin && git checkout origin/master').listen(9732)
Esempio n. 4
0
	var deploy_statement = sh_commands.deploy(deploy_type, repo_name, config.s3.bucket_name, path, config.s3.exclude);
	var deploy_result = sh.exec(deploy_statement);
	// Log deployment result
	console.log(deploy_result.stdout);
}

hookshot('refs/heads/master', function(info){
	// The last commit in the array is the most recent
	var most_recent_commit  = info.commits[info.commits.length - 1];

	var is_account_verified = verifyAccount(info.repository.owner.name),
	    deploy_status       = checkForDeployMsg(most_recent_commit);

	// Is this coming from the whitelisted GitHub account?
	if (is_account_verified){
		pullLatest(info);

		// Are we deploying? Has that option been enabled and does the commit have the appropriate message?
		if (config.s3.enabled && deploy_status){
			verifyCommitter(most_recent_commit, function(committer_approved){

				// Does the committer have deploy? privileges?
				if (committer_approved) deployToS3(deploy_status, info);
			
			});
		}

	}
}).listen(config.github_listener.port);

console.log('Listening on port... ' + config.github_listener.port);	
Esempio n. 5
0
var hookshot = require( 'hookshot' );

hookshot()
	.on( 'push', function onPush( info ) {
		'use strict';
		console.log( 'hookshot: ref ' + info.ref + ' was pushed.' );
	} );

hookshot( 'refs/heads/master', 'git pull' ).listen( 9095 );
Esempio n. 6
0
#!/usr/bin/env node

var hookshot = require("hookshot");
var spawn = require("child_process").spawn;
var options = require('minimist')(process.argv.slice(2));

var branch = options.b || options.branch;
var command = options.c || options.command;
var port = options.p || options.port;

if (!branch || !command || !port) {
  console.error("--branch, --command, and --port are all required.")
  process.exit(1);
}

hookshot('refs/heads/' + branch, command).listen(port);

console.log("18F Hub: Listening on port " + port + " for push events on " + branch + ".")
Esempio n. 7
0
hookshot('refs/heads/master', function(info) {
	//Get all the repos
	client.get('/'+apiPrefix+'/'+githubUser+'/repos', function (err, status, body) {
		console.log('*****************');
		console.log('*     DEBUG     *');
		console.log('*   structure   *');
		console.log('*    created    *');
		console.log('*****************');		
		console.log('├── docs/');
		console.log('│   ├── config.json');
		body.forEach(function(repo){
			client.get('/repos/'+githubUser+'/'+repo.name+'/contents/docs', function (err, status, files) {
				if(files !== undefined){
					files.forEach(function(file){
						if(file.name == 'config.json'){
							configJson.links[repo.name] = '/'+repo.name;
								fs.writeFile('docs/config.json', JSON.stringify(configJson), function(err) {
							});
							//This repo has a compatible doc let's crawl it!
							mkdirp('docs/'+repo.name, function (err) {
								if (err) throw err;
								client.get('/repos/'+githubUser+'/'+repo.name+'/contents/docs', function (err, status, docs) {
									console.log('│   ├── '+repo.name+'/');
									docs.forEach(function(doc){
										if(doc.type === 'file'){
											//it's a file we can created it right away
											console.log('│   │   ├── '+doc.name);
											client.get('/repos/'+githubUser+'/'+repo.name+'/contents/'+doc.path, function (err, status, content) {
												var crypted = new Buffer(content.content, 'base64')
												var decrypted = crypted.toString();
												fs.writeFile('docs/'+repo.name+'/'+doc.name, decrypted, function(err) {
												});
											});
										} else {
											//its a folder we need to go deeper
											mkdirp('docs/'+repo.name+'/'+doc.name, function (err) {
												client.get('/repos/'+githubUser+'/'+repo.name+'/contents/docs/'+doc.name, function (err, status, sub_docs) {
													console.log('│   │   ├── '+doc.name+'/');
													sub_docs.forEach(function(sub_doc){
													console.log('│   │   |   ├── '+sub_doc.name);
														client.get('/repos/'+githubUser+'/'+repo.name+'/contents/'+sub_doc.path, function (err, status, sub_content) {															
															var crypted = new Buffer(sub_content.content, 'base64')
															var decrypted = crypted.toString();
															fs.writeFile('docs/'+repo.name+'/'+doc.name+'/'+sub_content.name, decrypted, function(err) {
															});
														});
													});
												});
											});
										}
									});
								});
							});
						}
					});
				}
			});
		});
	});
}).listen(3000)