working deploy + sass compile test

This commit is contained in:
Jeremy Kauffman 2015-10-25 12:51:01 -04:00
parent 23d51a29f8
commit b06fb57ef7
6 changed files with 48 additions and 12 deletions

2
.gitignore vendored
View file

@ -1,4 +1,4 @@
/web/.sass-cache
.sass-cache
/web/css
/log
/data/secret

View file

@ -35,11 +35,21 @@ class Actions
public function executePostCommit()
{
$payload = json_decode($_REQUEST['payload']);
$secret = file_get_contents($_SERVER['ROOT_DIR'] . '/data/secret/github-secret');
$isToMaster = $payload->ref === 'refs/heads/master';
$payload = json_decode($_REQUEST['payload'], true);
$rawPost = file_get_contents('php://input');
$secret = trim(file_get_contents($_SERVER['ROOT_DIR'] . '/data/secret/github-secret'));
file_put_contents($_SERVER['ROOT_DIR'] . '/log/github.txt', ($isToMaster ? 'master' : 'apprentince') . "\n$secret\n" . print_r($payload, TRUE) . print_r($_REQUEST, true));
$this->returnErrorIf(!isset($_SERVER['HTTP_X_HUB_SIGNATURE']), "HTTP header 'X-Hub-Signature' is missing.");
list($algo, $hash) = explode('=', $_SERVER['HTTP_X_HUB_SIGNATURE'], 2) + array('', '');
$this->returnErrorIf(!in_array($algo, hash_algos(), TRUE), 'Invalid hash algorithm "' . $algo . '"');
$this->returnErrorIf($hash !== hash_hmac($algo, $rawPost, $secret), 'Hash does not match. "' . $secret . '"' . ' algo: ' . $algo . '$');
if ($payload['ref'] === 'refs/heads/master')
{
shell_exec($_SERVER['ROOT_DIR'] . '/deploy.sh > /dev/null 2>/dev/null &');
echo "Successful post commit.";
}
return [null, []];
}
@ -79,4 +89,18 @@ class Actions
return false;
}
//this is dumb
protected function returnError($error)
{
throw new ErrorException($error);
}
protected function returnErrorIf($condition, $error)
{
if ($condition)
{
$this->returnError($error);
}
}
}

View file

@ -0,0 +1,11 @@
<?php
/**
* Used to immediately end execution
*
* @author jeremy
*/
class StopException extends Exception
{
}

4
update.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
git checkout master && git pull
sass --update web/scss:web/css --style compressed

View file

@ -85,12 +85,9 @@
}
}
.photo-grid
.compile-test /*remove me*/
{
.photo-container
{
}
color: red;
}
@media(max-width: $max-text-width + 30)