update auto from git server, fixed checked
This commit is contained in:
+10
-7
@@ -31,8 +31,10 @@ final class Update {
|
||||
$_ainfo['cur_sha'] = substr($this->__web_app['GIT_SHA1'], 0, 10);
|
||||
$_ainfo['cur_sha1'] = $this->__web_app['GIT_SHA1'];
|
||||
$_ainfo['cur_date'] = $this->__web_app['GIT_DATE'];
|
||||
$_ainfo['svr_status'] = 1;
|
||||
$_ainfo['svr_message'] = "Server Online";
|
||||
$_ainfo['svr_status'] = 0;
|
||||
$_ainfo['svr_message'] = "Server Offline";
|
||||
|
||||
if (empty($this->__web_app['GIT_OWNER'] || empty($this->__web_app['GIT_REPO']) return $_ainfo;
|
||||
|
||||
try {
|
||||
$_url = "https://git.trifonia.cloud/api/v1/repos/".$this->__web_app['GIT_OWNER']."/".$this->__web_app['GIT_REPO']."/commits?limit=1";
|
||||
@@ -44,22 +46,23 @@ final class Update {
|
||||
$_ainfo['new_sha1'] = $ajson[0]['sha'];
|
||||
$_ainfo['new_date'] = date("d-m-Y H:i:s", strtotime($ajson[0]['created']));
|
||||
$_ainfo['new_message'] = $ajson[0]['commit']['message'];
|
||||
$_ainfo['svr_status'] = 1;
|
||||
$_ainfo['svr_message'] = "Server Online";
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$_ainfo['svr_status'] = 0;
|
||||
$_ainfo['svr_message'] = "Server Offline";
|
||||
}
|
||||
return $_ainfo;
|
||||
}
|
||||
|
||||
public function go_update($new_sha1, $new_date) {
|
||||
$_target = $this->__web_app['REAL_PATH'];
|
||||
$_branch = "main";
|
||||
if (isset($_target)) {
|
||||
chdir($_target);
|
||||
shell_exec("git pull");
|
||||
$output = shell_exec("cd {$_target} && git pull origin {$_branch} 2>&1");
|
||||
$this->__linkdb->Query("UPDATE app_config SET GIT_SHA1='".$new_sha1."',GIT_DATE='".$new_date."' WHERE REG_ID='".$this->__web_app['APP_CODE']."' LIMIT 1");
|
||||
return true;
|
||||
} else return false;
|
||||
return ['status'=>true,'message'=>$output];
|
||||
} else return ['status'=>false,'message'=>"Tanpa REAL_PATH !"];
|
||||
}
|
||||
|
||||
public function update_mysql() {
|
||||
|
||||
Reference in New Issue
Block a user