mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-02 11:26:28 +01:00
GitLab integration to websites.
This commit is contained in:
@@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="/static/baseTemplate/assets/themes/admin/layout.css">
|
<link rel="stylesheet" type="text/css" href="/static/baseTemplate/assets/themes/admin/layout.css">
|
||||||
<link rel="stylesheet" type="text/css" href="/static/baseTemplate/assets/themes/admin/color-schemes/default.css">
|
<link rel="stylesheet" type="text/css" href="/static/baseTemplate/assets/themes/admin/color-schemes/default.css">
|
||||||
|
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css">
|
||||||
|
|
||||||
<!-- Components theme, component below was above three CSS files. -->
|
<!-- Components theme, component below was above three CSS files. -->
|
||||||
|
|
||||||
|
|||||||
@@ -313,6 +313,7 @@ class ApplicationInstaller(multi.Thread):
|
|||||||
reponame = self.extraArgs['reponame']
|
reponame = self.extraArgs['reponame']
|
||||||
branch = self.extraArgs['branch']
|
branch = self.extraArgs['branch']
|
||||||
tempStatusPath = self.extraArgs['tempStatusPath']
|
tempStatusPath = self.extraArgs['tempStatusPath']
|
||||||
|
defaultProvider = self.extraArgs['defaultProvider']
|
||||||
|
|
||||||
statusFile = open(tempStatusPath, 'w')
|
statusFile = open(tempStatusPath, 'w')
|
||||||
statusFile.writelines('Checking if GIT installed..,0')
|
statusFile.writelines('Checking if GIT installed..,0')
|
||||||
@@ -416,7 +417,7 @@ class ApplicationInstaller(multi.Thread):
|
|||||||
try:
|
try:
|
||||||
|
|
||||||
command = 'sudo GIT_SSH_COMMAND="ssh -i /root/.ssh/cyberpanel -o StrictHostKeyChecking=no" git clone ' \
|
command = 'sudo GIT_SSH_COMMAND="ssh -i /root/.ssh/cyberpanel -o StrictHostKeyChecking=no" git clone ' \
|
||||||
'--depth 1 --no-single-branch git@github.com:' + username + '/' + reponame + '.git -b ' + branch + ' ' + finalPath
|
'--depth 1 --no-single-branch git@' + defaultProvider +'.com:' + username + '/' + reponame + '.git -b ' + branch + ' ' + finalPath
|
||||||
result = subprocess.check_output(shlex.split(command))
|
result = subprocess.check_output(shlex.split(command))
|
||||||
|
|
||||||
except subprocess.CalledProcessError, msg:
|
except subprocess.CalledProcessError, msg:
|
||||||
|
|||||||
@@ -4247,6 +4247,12 @@ app.controller('setupGit', function($scope, $http, $timeout) {
|
|||||||
$scope.installProg = true;
|
$scope.installProg = true;
|
||||||
$scope.goBackDisable = true;
|
$scope.goBackDisable = true;
|
||||||
|
|
||||||
|
var defaultProvider = 'github';
|
||||||
|
|
||||||
|
$scope.setProvider = function (provider) {
|
||||||
|
defaultProvider = provider;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
var statusFile;
|
var statusFile;
|
||||||
var domain = $("#domainNamePage").text();
|
var domain = $("#domainNamePage").text();
|
||||||
@@ -4284,7 +4290,7 @@ app.controller('setupGit', function($scope, $http, $timeout) {
|
|||||||
$scope.installationSuccessfull = false;
|
$scope.installationSuccessfull = false;
|
||||||
$scope.couldNotConnect = true;
|
$scope.couldNotConnect = true;
|
||||||
$scope.gitLoading = true;
|
$scope.gitLoading = true;
|
||||||
$scope.goBackDisable = false;
|
$scope.goBackDisable = true;
|
||||||
|
|
||||||
$scope.installationURL = domain;
|
$scope.installationURL = domain;
|
||||||
|
|
||||||
@@ -4355,7 +4361,8 @@ app.controller('setupGit', function($scope, $http, $timeout) {
|
|||||||
domain: domain,
|
domain: domain,
|
||||||
username: $scope.githubUserName,
|
username: $scope.githubUserName,
|
||||||
reponame: $scope.githubRepo,
|
reponame: $scope.githubRepo,
|
||||||
branch: $scope.githubBranch
|
branch: $scope.githubBranch,
|
||||||
|
defaultProvider: defaultProvider
|
||||||
};
|
};
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
|
|||||||
@@ -4247,6 +4247,12 @@ app.controller('setupGit', function($scope, $http, $timeout) {
|
|||||||
$scope.installProg = true;
|
$scope.installProg = true;
|
||||||
$scope.goBackDisable = true;
|
$scope.goBackDisable = true;
|
||||||
|
|
||||||
|
var defaultProvider = 'github';
|
||||||
|
|
||||||
|
$scope.setProvider = function (provider) {
|
||||||
|
defaultProvider = provider;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
var statusFile;
|
var statusFile;
|
||||||
var domain = $("#domainNamePage").text();
|
var domain = $("#domainNamePage").text();
|
||||||
@@ -4355,7 +4361,8 @@ app.controller('setupGit', function($scope, $http, $timeout) {
|
|||||||
domain: domain,
|
domain: domain,
|
||||||
username: $scope.githubUserName,
|
username: $scope.githubUserName,
|
||||||
reponame: $scope.githubRepo,
|
reponame: $scope.githubRepo,
|
||||||
branch: $scope.githubBranch
|
branch: $scope.githubBranch,
|
||||||
|
defaultProvider: defaultProvider
|
||||||
};
|
};
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
|
|||||||
@@ -13,7 +13,9 @@
|
|||||||
<p>{% trans "Attach git to your website" %}</p>
|
<p>{% trans "Attach git to your website" %}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-controller="setupGit" class="panel">
|
{% if not installed %}
|
||||||
|
|
||||||
|
<div ng-controller="setupGit" class="panel">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<h3 class="title-hero">
|
<h3 class="title-hero">
|
||||||
<span id="domainNamePage">{{ domainName }}</span> - {% trans "Attach Git" %} <img ng-hide="gitLoading" src="{% static 'images/loading.gif' %}">
|
<span id="domainNamePage">{{ domainName }}</span> - {% trans "Attach Git" %} <img ng-hide="gitLoading" src="{% static 'images/loading.gif' %}">
|
||||||
@@ -24,7 +26,7 @@
|
|||||||
<li class="col-md-3 active">
|
<li class="col-md-3 active">
|
||||||
<a href="#tab-example-1" data-toggle="tab" class="list-group-item">
|
<a href="#tab-example-1" data-toggle="tab" class="list-group-item">
|
||||||
<i class="glyph-icon icon-dashboard"></i>
|
<i class="glyph-icon icon-dashboard"></i>
|
||||||
{% trans "Github" %}
|
{% trans "Providers" %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
@@ -42,6 +44,23 @@
|
|||||||
<div class="tab-pane fade active in" id="tab-example-1">
|
<div class="tab-pane fade active in" id="tab-example-1">
|
||||||
<div class="example-box-wrapper">
|
<div class="example-box-wrapper">
|
||||||
|
|
||||||
|
<ul class="list-group row">
|
||||||
|
<li class="col-md-3">
|
||||||
|
<a href="" ng-click="setProvider('github')" class="list-group-item">
|
||||||
|
<i class="fa fa-github" aria-hidden="true"></i>
|
||||||
|
Github
|
||||||
|
<i class="glyph-icon icon-chevron-right"></i>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="col-md-3">
|
||||||
|
<a href="" ng-click="setProvider('gitlab')" class="list-group-item">
|
||||||
|
<i class="fa fa-gitlab" aria-hidden="true"></i>
|
||||||
|
GitLab
|
||||||
|
<i class="glyph-icon font-green icon-chevron-right"></i>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<form action="/" class="form-horizontal bordered-row">
|
<form action="/" class="form-horizontal bordered-row">
|
||||||
|
|
||||||
<div ng-hide="installationDetailsForm" class="form-group">
|
<div ng-hide="installationDetailsForm" class="form-group">
|
||||||
@@ -49,7 +68,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-hide="installationDetailsForm" class="form-group">
|
<div ng-hide="installationDetailsForm" class="form-group">
|
||||||
<label class="col-sm-3 control-label">{% trans "Github Username" %}</label>
|
<label class="col-sm-3 control-label">{% trans "Username" %}</label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<input type="text" class="form-control" ng-model="githubUserName" required>
|
<input type="text" class="form-control" ng-model="githubUserName" required>
|
||||||
</div>
|
</div>
|
||||||
@@ -173,6 +192,102 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
<div ng-controller="setupGit" class="panel">
|
||||||
|
<div class="panel-body">
|
||||||
|
<h3 class="title-hero">
|
||||||
|
<span id="domainNamePage">{{ domainName }}</span> <img ng-hide="gitLoading" src="{% static 'images/loading.gif' %}">
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<div class="example-box-wrapper">
|
||||||
|
<ul class="list-group list-group-separator row list-group-icons">
|
||||||
|
|
||||||
|
<li class="col-md-3 active">
|
||||||
|
<a href="#tab-example-1" data-toggle="tab" class="list-group-item">
|
||||||
|
<i class="fa fa-git" aria-hidden="true"></i>
|
||||||
|
{% trans 'Manage' %}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="col-md-3">
|
||||||
|
<a href="#tab-example-3" data-toggle="tab" class="list-group-item">
|
||||||
|
<i class="fa fa-tree" aria-hidden="true"></i>
|
||||||
|
{% trans 'Change Branch' %}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div class="tab-content">
|
||||||
|
<div class="tab-pane fade active in" id="tab-example-1">
|
||||||
|
<ul class="list-group row">
|
||||||
|
<li class="col-md-3">
|
||||||
|
<a href="" ng-click="setProvider('github')" class="list-group-item">
|
||||||
|
<i class="fa fa-github" aria-hidden="true"></i>
|
||||||
|
Detach Repo
|
||||||
|
<i class="glyph-icon icon-chevron-right"></i>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div class="alert alert-info">
|
||||||
|
<h4 class="alert-title">{% trans 'Webhook URL' %}</h4>
|
||||||
|
<p>{% trans "Add this URL to Webhooks section of your Git respository, if you've used hostname SSL then replace IP with your hostname. Otherwise use IP and disable SSL check while configuring webhook. This will initiate a pull from your resposity as soon as you commit some changes."%} <code>{{ webhookURL }}</code></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="tab-pane fade" id="tab-example-3">
|
||||||
|
|
||||||
|
<form action="/" class="form-horizontal bordered-row">
|
||||||
|
|
||||||
|
<div ng-hide="installationDetailsForm" class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">{% trans "Branch" %}</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input type="text" class="form-control" ng-model="githubBranch" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div ng-hide="installationDetailsForm" class="form-group">
|
||||||
|
<label class="col-sm-3 control-label"></label>
|
||||||
|
<div class="col-sm-4">
|
||||||
|
<button type="button" ng-click="attachRepo()" class="btn btn-primary btn-lg btn-block">{% trans "Change Branch" %}</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div ng-hide="" class="form-group">
|
||||||
|
<label class="col-sm-2 control-label"></label>
|
||||||
|
<div class="col-sm-7">
|
||||||
|
|
||||||
|
<div ng-hide="failedMesg" class="alert alert-danger">
|
||||||
|
<p>{% trans "Error message:" %} {$ errorMessage $}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div ng-hide="successMessage" class="alert alert-success">
|
||||||
|
<p>{% trans "Branch successfully changed." %}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div ng-hide="couldNotConnect" class="alert alert-danger">
|
||||||
|
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -2511,10 +2511,24 @@ def setupGit(request, domain):
|
|||||||
if website.admin != admin:
|
if website.admin != admin:
|
||||||
raise BaseException('You do not own this website.')
|
raise BaseException('You do not own this website.')
|
||||||
|
|
||||||
command = 'sudo cat /root/.ssh/cyberpanel.pub'
|
|
||||||
deploymentKey = subprocess.check_output(shlex.split(command)).strip('\n')
|
|
||||||
|
|
||||||
return render(request, 'websiteFunctions/setupGit.html', {'domainName' : domain, 'deploymentKey': deploymentKey})
|
path = '/home/cyberpanel/' + domain + '.git'
|
||||||
|
|
||||||
|
if os.path.exists(path):
|
||||||
|
|
||||||
|
ipFile = "/etc/cyberpanel/machineIP"
|
||||||
|
f = open(ipFile)
|
||||||
|
ipData = f.read()
|
||||||
|
ipAddress = ipData.split('\n', 1)[0]
|
||||||
|
|
||||||
|
webhookURL = 'https://' + ipAddress + ':8090/websites/' + domain + '/gitNotify'
|
||||||
|
return render(request, 'websiteFunctions/setupGit.html',
|
||||||
|
{'domainName': domain, 'installed': 1, 'webhookURL': webhookURL})
|
||||||
|
else:
|
||||||
|
command = 'sudo cat /root/.ssh/cyberpanel.pub'
|
||||||
|
deploymentKey = subprocess.check_output(shlex.split(command)).strip('\n')
|
||||||
|
|
||||||
|
return render(request, 'websiteFunctions/setupGit.html', {'domainName' : domain, 'deploymentKey': deploymentKey, 'installed': 0})
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||||
return HttpResponse(str(msg))
|
return HttpResponse(str(msg))
|
||||||
@@ -2539,6 +2553,7 @@ def setupGitRepo(request):
|
|||||||
extraArgs['reponame'] = data['reponame']
|
extraArgs['reponame'] = data['reponame']
|
||||||
extraArgs['branch'] = data['branch']
|
extraArgs['branch'] = data['branch']
|
||||||
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
|
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||||
|
extraArgs['defaultProvider'] = data['defaultProvider']
|
||||||
|
|
||||||
|
|
||||||
background = ApplicationInstaller('git', extraArgs)
|
background = ApplicationInstaller('git', extraArgs)
|
||||||
|
|||||||
Reference in New Issue
Block a user