mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 17:47:26 +00:00
fix autoupdate setup
This commit is contained in:
parent
c03dd921e2
commit
9f8dc71c37
4 changed files with 24 additions and 12 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
||||||
.sass-cache
|
.sass-cache
|
||||||
/data/config.php
|
/data/config.php
|
||||||
|
/data/writeable/*
|
||||||
/web/css/*
|
/web/css/*
|
||||||
/log
|
/log
|
||||||
/web/zohoverify
|
/web/zohoverify
|
||||||
|
|
|
@ -10,20 +10,18 @@ class OpsActions extends Actions
|
||||||
public static function executePostCommit()
|
public static function executePostCommit()
|
||||||
{
|
{
|
||||||
$payload = json_decode($_REQUEST['payload'], true);
|
$payload = json_decode($_REQUEST['payload'], true);
|
||||||
$rawPost = file_get_contents('php://input');
|
if ($payload['ref'] === 'refs/heads/master')
|
||||||
$secret = Config::get('github_key');
|
{
|
||||||
|
|
||||||
Actions::returnErrorIf(!isset($_SERVER['HTTP_X_HUB_SIGNATURE']), "HTTP header 'X-Hub-Signature' is missing.");
|
Actions::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('', '');
|
list($algo, $hash) = explode('=', $_SERVER['HTTP_X_HUB_SIGNATURE'], 2) + array('', '');
|
||||||
Actions::returnErrorIf(!in_array($algo, hash_algos(), TRUE), 'Invalid hash algorithm "' . $algo . '"');
|
Actions::returnErrorIf(!in_array($algo, hash_algos(), TRUE), 'Invalid hash algorithm "' . $algo . '"');
|
||||||
|
|
||||||
|
$rawPost = file_get_contents('php://input');
|
||||||
|
$secret = Config::get('github_key');
|
||||||
Actions::returnErrorIf($hash !== hash_hmac($algo, $rawPost, $secret), 'Hash does not match. "' . $secret . '"' . ' algo: ' . $algo . '$');
|
Actions::returnErrorIf($hash !== hash_hmac($algo, $rawPost, $secret), 'Hash does not match. "' . $secret . '"' . ' algo: ' . $algo . '$');
|
||||||
|
|
||||||
if ($payload['ref'] === 'refs/heads/master')
|
file_put_contents(ROOT_DIR . '/data/writeable/NEEDS_UPDATE', '');
|
||||||
{
|
|
||||||
$ret = shell_exec('sudo -u lbry ' . ROOT_DIR . '/update.php 2>&1');
|
|
||||||
echo "Successful post commit (aka the script executed, so maybe it is successful):\n";
|
|
||||||
echo $ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return [null, []];
|
return [null, []];
|
||||||
|
|
0
data/writeable/.gitkeep
Normal file
0
data/writeable/.gitkeep
Normal file
13
update.php
13
update.php
|
@ -3,6 +3,19 @@
|
||||||
|
|
||||||
include __DIR__.'/bootstrap.php';
|
include __DIR__.'/bootstrap.php';
|
||||||
|
|
||||||
|
$options = getopt('f');
|
||||||
|
$force = isset($options['f']); // update even if no NEEDS_UPDATE file exists
|
||||||
|
|
||||||
|
$needsUpdateFile = ROOT_DIR . '/data/writeable/NEEDS_UPDATE';
|
||||||
|
if (!$force && !file_exists($needsUpdateFile))
|
||||||
|
{
|
||||||
|
echo "No update necessary\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
unlink($needsUpdateFile);
|
||||||
|
|
||||||
|
|
||||||
chdir(ROOT_DIR);
|
chdir(ROOT_DIR);
|
||||||
|
|
||||||
Shell::exec('git fetch && git reset --hard origin/master');
|
Shell::exec('git fetch && git reset --hard origin/master');
|
||||||
|
|
Loading…
Add table
Reference in a new issue