Files
codefever/git-storage/hooks/main
Carney Wu d3de96487f initial version (#1)
* fix(Useless Code): remove useless code

* feat(Deploy Scripts): add deploy scripts

* fix(Delopy Script): change settings

* fix(Deploy Script): fix ssh-keygen script

* fix(Deploy Script): change env file path

* feat(Deploy Script): add db migration

* fix(Deploy script): change script

* feat(Deploy Script): add sql file to create database

* fix(Deploy Script): add composer support

* fix(Deploy Script): add composer

* fix(Service Script): add http gateway

* fix(Deploy Script): add git path

* fix(Deploy Script): fix setting bugs

* fix(Init Script): get user from config

* fix(Service): adjust run users

* feat(Doc): add doc

* fix(Doc): change docs

* fix(Deploy script): change owner of storage path

* feat: codefever-community documentation system

* fix(Doc): doc details page style

* feat: fix page navigation

* fix(SQL File): fix db file fit MySQL 5.7

* fix(FileTree): empty repository display

* fix: fix helper navigation

* docs(zh-cn essential part):

* fix(Doc Style): change markdown.css

* docs(contribution doc):

* fix: unified page style

* docs(Readme): add readme

* build(Build):

Co-authored-by: cubic <carneywu@pgyer.com>
Co-authored-by: pololi <pololi@pgyer.com>
Co-authored-by: yangchen <chenyang@pgyer.com>
2022-01-19 17:21:59 +08:00

59 lines
1.5 KiB
PHP
Executable File

#!/usr/local/php/bin/php
<?php
$config = yaml_parse_file(dirname(__FILE__, 3) . '/env.yaml');
if ($config['gateway'] && $config['gateway']['token'] && $config['gateway']['hooks']) {
$config = [
'endpoint' => $config['gateway']['hooks'],
'token' => $config['gateway']['token']
];
} else {
echo '[CodeFever Community]: Bad configuration, Contact site administrator if operation rejected!.';
exit(255);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $config['endpoint']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Token: ' . $config['token'],
'Content-Type: application/json',
'Accept: application/json',
]);
curl_setopt($ch, CURLOPT_POST, 1);
$input = fopen('php://stdin', 'r');
stream_set_blocking($input, 0);
$data = [
'uid' => getenv('PGYER_UID'),
'args' => $argv,
'stdin' => stream_get_contents($input)
];
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, TRUE);
if ($result) {
if (!$result['code']) {
if ($result['data'] && $result['data']['remote']) {
echo $result['data']['remote'];
}
exit(0);
} else {
echo 'Operation Stopped: ';
if ($result['data'] && $result['data']['remote']) {
echo $result['data']['remote'] . "\n";
}
echo 'Request-ID: ' . $result['request-id'] . "\n";
}
} else {
echo 'Contact site administrator if operation rejected!';
}
exit(255);