-
Notifications
You must be signed in to change notification settings - Fork 5
/
gitpress.php
executable file
·72 lines (55 loc) · 1.59 KB
/
gitpress.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/*
Plugin Name: Gitpress
Plugin URI: https://github.com/naveen17797/gitpress
Description: Run your wordpress site on github or gitlab
Version: 1.0.1
Author: Naveen Muthusamy
Author URI: http://github.com/naveen17797/
License: GPL2
*/
use Gitpress\Actions\CloneRepoAction;
use Gitpress\Actions\CommitAction;
use Gitpress\Actions\PushAction;
use Gitpress\Actions\ShouldDoSyncAction;
use Gitpress\AdminBar\AdminBar;
use Gitpress\Notification\Notification;
require_once __DIR__ . "/simply-static/simply-static.php";
add_action( 'init', function () {
require_once __DIR__ . '/configuration.php';
} );
require_once __DIR__ . "/autoloader.php";
add_action( 'init', function () {
new Notification();
new AdminBar();
} );
function gitPressExecCommand( $bin, $command = '', $force = true ) {
$stream = null;
$bin .= $force ? ' 2>&1' : '';
$descriptorSpec = array
(
0 => array( 'pipe', 'r' ),
1 => array( 'pipe', 'w' )
);
$process = proc_open( $bin, $descriptorSpec, $pipes );
if ( is_resource( $process ) ) {
fwrite( $pipes[0], $command );
fclose( $pipes[0] );
$stream = stream_get_contents( $pipes[1] );
fclose( $pipes[1] );
proc_close( $process );
}
return $stream;
}
/**
* Following is the sequence of actions which the client should call
*
* 1. Call ShouldDoSyncAction and verify if we have all credentials to do a sync, can_proceed_next_action.
* 2. Clone the repo and start the procedure.
* 3. Once the procedure ends then commit the changes
* 4. Call push action and end the sync.
*/
new ShouldDoSyncAction();
new CloneRepoAction();
new CommitAction();
new PushAction();