Compare commits
12 Commits
0ffcafdf3f
...
main
Author | SHA1 | Date | |
---|---|---|---|
379da7e455 | |||
3c49a65c5d | |||
025435b48e | |||
46224bdf6d | |||
4e1736709e | |||
cc8026f688 | |||
1086d648de | |||
52e1348613 | |||
ee556d859e | |||
a9414ff6ce | |||
b17ab480a4 | |||
6f637968bd |
30
.gitea/workflows/deploy.yml
Normal file
30
.gitea/workflows/deploy.yml
Normal file
@ -0,0 +1,30 @@
|
||||
name: Deployment Pipeline
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: Setup SSH
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
||||
chmod 600 ~/.ssh/id_rsa
|
||||
ssh-keyscan omega.raphix.fr >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Deploy Stage
|
||||
run: |
|
||||
echo "[Neutral] - Deploy Stage"
|
||||
ssh -o StrictHostKeyChecking=no raphix@raphix.fr sudo apt update -y
|
||||
ssh -o StrictHostKeyChecking=no raphix@raphix.fr sudo apt upgrade -y
|
||||
ssh -o StrictHostKeyChecking=no raphix@raphix.fr sudo -S -u gitlab-ci /home/gitlab-ci/neutral_deploy.sh
|
||||
|
19
Jenkinsfile
vendored
19
Jenkinsfile
vendored
@ -1,19 +0,0 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
stages {
|
||||
stage('[Neutral] - Déploiement') {
|
||||
steps {
|
||||
script {
|
||||
|
||||
echo "[Neutral-Deploy] - Deploy Stage"
|
||||
sh "ssh raphix@raphix.fr sudo apt update -y"
|
||||
sh "ssh raphix@raphix.fr sudo apt upgrade -y"
|
||||
sh "ssh raphix@raphix.fr sudo -S -u gitlab-ci /home/gitlab-ci/neutral_deploy.sh"
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -37,12 +37,11 @@ module.exports.updateFile = function (file) {
|
||||
|
||||
module.exports.getSettings = function () {
|
||||
const file = this.getFile()
|
||||
return {"jenkins_token": file.JENKINS_TOKEN, "omega_token": file.OMEGA_KEY}
|
||||
return {"omega_token": file.OMEGA_KEY}
|
||||
}
|
||||
|
||||
module.exports.saveSettings = function (settings) {
|
||||
const file = this.getFile()
|
||||
file.JENKINS_TOKEN = settings.jenkins_token
|
||||
file.OMEGA_KEY = settings.omega_token
|
||||
this.updateFile(file)
|
||||
}
|
||||
|
@ -164,14 +164,7 @@ module.exports.getFile = function(root) {
|
||||
|
||||
try {
|
||||
|
||||
// Check if the file is an image and if it is return the base64
|
||||
if(mime.lookup(root).includes("image")) {
|
||||
return "data:" + mime.lookup(root) + ";base64," + fs.readFileSync(root, "base64")
|
||||
} else {
|
||||
return fs.readFileSync(root, "utf-8")
|
||||
}
|
||||
|
||||
|
||||
} catch(err) {
|
||||
console.log(err)
|
||||
return "NOT_PERMITTED"
|
||||
|
138
bin/pipelines.js
138
bin/pipelines.js
@ -1,138 +0,0 @@
|
||||
const { LogType } = require("loguix")
|
||||
const fs = require("fs")
|
||||
const path = require("path")
|
||||
const { __glob } = require("./global-variables")
|
||||
const clog = new LogType("Pïpeline")
|
||||
const config = require("./config")
|
||||
|
||||
const tokenkey = config.getFile().JENKINS_TOKEN
|
||||
|
||||
module.exports.getAllPipelines = function() {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
|
||||
fetch(`https://jenkins.raphix.fr/api/json`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Accept": "application/json",
|
||||
"Authorization": `Basic ${tokenkey}`
|
||||
},
|
||||
credentials: "include"
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(async list => {
|
||||
|
||||
const pipelinesJobs = new Array()
|
||||
|
||||
for(const job of list.jobs) {
|
||||
await fetch(`${job.url}/api/json`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Accept": "application/json",
|
||||
"Authorization": `Basic ${tokenkey}`
|
||||
},
|
||||
credentials: "include"
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(async res => {
|
||||
|
||||
if(res._class == "org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject") {
|
||||
await getJobMain(res).then(resJ => {
|
||||
res.jobs[0] = resJ
|
||||
pipelinesJobs.push(res)
|
||||
})
|
||||
} else {
|
||||
pipelinesJobs.push(res)
|
||||
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
list.jobs = pipelinesJobs
|
||||
|
||||
resolve(list)
|
||||
|
||||
|
||||
})
|
||||
.catch(err => {
|
||||
resolve("UNAVAILABLE")
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
module.exports.startPipeline = function(pipeline) {
|
||||
|
||||
|
||||
// If it's a freestyle job, build with params
|
||||
|
||||
if(pipeline.type == "org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject") {
|
||||
return new Promise((resolve, reject) => {
|
||||
fetch(`${pipeline.url}/job/${pipeline.jobname}/build?delay=0sec`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Authorization": `Basic ${tokenkey}`
|
||||
},
|
||||
credentials: "include"
|
||||
})
|
||||
.then(res => {
|
||||
resolve("OK")
|
||||
})
|
||||
})
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
const parameters = pipeline.fields
|
||||
|
||||
const formatedParams = new URLSearchParams()
|
||||
|
||||
for(const param of parameters) {
|
||||
formatedParams.append(param.name, param.value)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
fetch(`${pipeline.url}/buildWithParameters?delay=0sec`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Authorization": `Basic ${tokenkey}`,
|
||||
"Content-Type": "application/x-www-form-urlencoded"
|
||||
},
|
||||
credentials: "include",
|
||||
body: formatedParams
|
||||
})
|
||||
.then(res => {
|
||||
resolve("OK")
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function getJobMain(res) {
|
||||
|
||||
return new Promise(async (resolve, reject) => {
|
||||
|
||||
await fetch(`${res.jobs[0].url}/api/json`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Authorization': `Basic ${tokenkey}`
|
||||
},
|
||||
credentials: 'include'
|
||||
}).then(res => res.json())
|
||||
.then(res => {
|
||||
resolve(res)
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
|
||||
}
|
@ -8,7 +8,6 @@ const files = require("./files.js")
|
||||
const config = require("./config.js")
|
||||
const links = require("./links.js")
|
||||
const service = require("./services.js")
|
||||
const pipeline = require("./pipelines.js")
|
||||
const plog = new LogType("Web")
|
||||
const cook = require("cookie")
|
||||
const http = require("http")
|
||||
@ -166,16 +165,6 @@ module.exports.serverIO = function(server) {
|
||||
});
|
||||
}
|
||||
|
||||
if(user.checkPermission("PIPELINES")) {
|
||||
GetRequest("PL_GET_ALL", async () => {
|
||||
GetAnswer("PL_GET_ALL", await pipeline.getAllPipelines())
|
||||
})
|
||||
|
||||
PostRequest("PL_START", async (settings) => {
|
||||
PostAnswer("PL_START", await pipeline.startPipeline(settings))
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
if(user.checkPermission("USERS")) {
|
||||
GetRequest("US_ALL", async () => {
|
||||
|
@ -55,9 +55,6 @@ module.exports.stopService = function(service) {
|
||||
} else if(service == `https://raphix.fr`) {
|
||||
let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@alpha.raphix.fr sudo -S -u gitlab-ci 'pm2 stop "Website - Raphix"'`)
|
||||
resolve("OK")
|
||||
} else if(service == `https://cv.raphix.fr`) {
|
||||
let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@alpha.raphix.fr sudo -S -u gitlab-ci 'pm2 stop "CV - Raphael"'`)
|
||||
resolve("OK")
|
||||
} else if(service == `http://omega.raphix.fr:2333`) {
|
||||
let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@omega.raphix.fr sudo -S systemctl stop lavalink `)
|
||||
resolve("OK")
|
||||
@ -89,9 +86,6 @@ module.exports.startService = function(service) {
|
||||
} else if(service == `https://raphix.fr`) {
|
||||
let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@alpha.raphix.fr sudo -S -u gitlab-ci 'pm2 start /home/gitlab-ci/website.config.js'`)
|
||||
resolve("OK")
|
||||
} else if(service == `https://cv.raphix.fr`) {
|
||||
let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@alpha.raphix.fr sudo -S -u gitlab-ci 'pm2 start /home/gitlab-ci/cv.config.js'`)
|
||||
resolve("OK")
|
||||
} else if(service == `http://omega.raphix.fr:2333`) {
|
||||
let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@omega.raphix.fr sudo -S systemctl start lavalink `)
|
||||
resolve("OK")
|
||||
@ -122,9 +116,6 @@ module.exports.restartService = function(service) {
|
||||
} else if(service == `https://raphix.fr`) {
|
||||
let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@alpha.raphix.fr sudo -S -u gitlab-ci 'pm2 restart "Website - Raphix"'`)
|
||||
resolve("OK")
|
||||
} else if(service == `https://cv.raphix.fr`) {
|
||||
let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@alpha.raphix.fr sudo -S -u gitlab-ci 'pm2 restart "CV - Raphael"'`)
|
||||
resolve("OK")
|
||||
} else if(service == `http://omega.raphix.fr:2333`) {
|
||||
let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@omega.raphix.fr sudo -S systemctl restart lavalink `)
|
||||
resolve("OK")
|
||||
|
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "neutral",
|
||||
"version": "0.7.0",
|
||||
"version": "1.0.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "neutral",
|
||||
"version": "0.7.0",
|
||||
"version": "1.0.3",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"cookie-parser": "~1.4.4",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "neutral",
|
||||
"version": "1.1.0",
|
||||
"version": "1.0.4",
|
||||
"description": "Panel d'administration de Raphix",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
@ -733,10 +733,12 @@ class Service {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/*
|
||||
|
||||
* Permet de créer un composant de vue de type "Pipeline"
|
||||
* @param {object} properties Propriétés du composant de vue
|
||||
*/
|
||||
|
||||
|
||||
class Pipeline {
|
||||
name;
|
||||
@ -954,6 +956,8 @@ class Pipeline {
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
class User {
|
||||
constructor(properties) {
|
||||
this.username = properties.username
|
||||
@ -1027,10 +1031,7 @@ class User {
|
||||
<input type="checkbox" id="${this.username}_perm_SERVERS">
|
||||
<label for="${this.username}_perm_SERVERS">Serveurs</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" id="${this.username}_perm_PIPELINES">
|
||||
<label for="${this.username}_perm_PIPELINES">Pipelines</label>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<input type="checkbox" id="${this.username}_perm_METRICS">
|
||||
<label for="${this.username}_perm_METRICS">Metrics</label>
|
||||
@ -1090,7 +1091,7 @@ class User {
|
||||
editPermissions.push(getID(`${this.username}_perm_SERVICES`))
|
||||
editPermissions.push(getID(`${this.username}_perm_LINKS`))
|
||||
editPermissions.push(getID(`${this.username}_perm_SERVERS`))
|
||||
editPermissions.push(getID(`${this.username}_perm_PIPELINES`))
|
||||
|
||||
editPermissions.push(getID(`${this.username}_perm_METRICS`))
|
||||
editPermissions.push(getID(`${this.username}_perm_USERS`))
|
||||
editPermissions.push(getID(`${this.username}_perm_SETTINGS`))
|
||||
|
@ -590,7 +590,6 @@ explorer.createWindow(() => {
|
||||
})
|
||||
} else {
|
||||
// Make Download using result
|
||||
|
||||
const element = document.createElement('a');
|
||||
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(result));
|
||||
element.setAttribute('download', file.name);
|
||||
@ -598,6 +597,7 @@ explorer.createWindow(() => {
|
||||
document.body.appendChild(element);
|
||||
element.click();
|
||||
document.body.removeChild(element);
|
||||
|
||||
}
|
||||
})
|
||||
})
|
||||
@ -614,15 +614,7 @@ explorer.createWindow(() => {
|
||||
|
||||
function editFile() {
|
||||
const reqFiles = post("FX_GETFILE", file.fileDirectory)
|
||||
//Create a popup for the loading
|
||||
|
||||
View.createPopup({
|
||||
title: `<i class='fa-solid fa-file-pen'></i> Editeur`,
|
||||
content: `<p><i class='fa-solid fa-rotate fa-spin'></i> Chargement en cours ...</p>`
|
||||
})
|
||||
|
||||
reqFiles.then((result) => {
|
||||
View.destroyPopup(`<i class='fa-solid fa-file-pen'></i> Editeur}`)
|
||||
if(result == "NOT_PERMITTED") {
|
||||
View.createPopup({
|
||||
title: `<i class='fa fa-warning'></i> Erreur`,
|
||||
@ -632,18 +624,9 @@ explorer.createWindow(() => {
|
||||
const editor = new ViewWindow({
|
||||
title: `<i class="fa-solid fa-file-pen"></i> Editeur - ${file.fileDirectory}`,
|
||||
width: "1000px",
|
||||
height: "650px"
|
||||
height: "600px"
|
||||
})
|
||||
|
||||
|
||||
if(file.type == "image/png" | file.type == "image/jpeg") {
|
||||
editor.setContent(`
|
||||
<div style='width: 100%; text-align: center;'>
|
||||
<img style='width: 500px;' src='${result}'/>
|
||||
</div>`)
|
||||
|
||||
|
||||
} else {
|
||||
editor.setContent(`
|
||||
|
||||
<div class='fx-bar'>
|
||||
@ -651,8 +634,10 @@ explorer.createWindow(() => {
|
||||
</div>
|
||||
<textarea id='${editor.getViewTitle()}_editorContent' class='fx-editor-content'>${result}</textarea>
|
||||
|
||||
|
||||
`)
|
||||
|
||||
|
||||
const editorSave = getID(editor.getViewTitle() + "_save")
|
||||
const editorContent = getID(editor.getViewTitle() + "_editorContent")
|
||||
|
||||
@ -688,7 +673,7 @@ explorer.createWindow(() => {
|
||||
editorContent.style.resize = "none"
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -22,11 +22,13 @@ const explorer = new ViewComponent({
|
||||
permission: "SERVERS"
|
||||
})
|
||||
|
||||
/*
|
||||
|
||||
const pipelines = new ViewComponent({
|
||||
name: "Gestion des pipelines",
|
||||
icon: "fa-solid fa-code-merge",
|
||||
permission: "PIPELINES"
|
||||
})
|
||||
})*/
|
||||
|
||||
const metrics = new ViewComponent({
|
||||
name: "Web Metrik",
|
||||
|
@ -30,15 +30,6 @@ services.createWindow(async () => {
|
||||
|
||||
})
|
||||
|
||||
const jenkinsService = new Service({
|
||||
name: "Jenkins",
|
||||
description: "Gestionnaire de pipeline",
|
||||
icon: "/images/services/jenkins.svg",
|
||||
url: "https://jenkins.raphix.fr" ,
|
||||
canAccess: true,
|
||||
View: View
|
||||
|
||||
})
|
||||
|
||||
const raphixwebsite = new Service({
|
||||
name: "Raphix.fr",
|
||||
@ -50,39 +41,17 @@ services.createWindow(async () => {
|
||||
|
||||
})
|
||||
|
||||
const cvraphix = new Service({
|
||||
name: "CV Raphix",
|
||||
description: "Curriculum Vitae de Raphix",
|
||||
icon: "/images/services/cv.png",
|
||||
url: "https://cv.raphix.fr",
|
||||
canAccess: true,
|
||||
View: View
|
||||
})
|
||||
|
||||
const lavalink = new Service({
|
||||
name: "Lavalink",
|
||||
description: "Serveur Lavalink pour Subsonics",
|
||||
icon: "/images/services/lavalink.svg",
|
||||
url: "http://omega.raphix.fr:2333",
|
||||
canAccess: false,
|
||||
View: View
|
||||
})
|
||||
|
||||
allServices.push(subsonicsService.generateHTML())
|
||||
allServices.push(lavalink.generateHTML())
|
||||
allServices.push(giteaService.generateHTML())
|
||||
allServices.push(jenkinsService.generateHTML())
|
||||
allServices.push(raphixwebsite.generateHTML())
|
||||
allServices.push(cvraphix.generateHTML())
|
||||
|
||||
View.setContent(`<div class='sv-list'>${allServices.join("")}</div>`)
|
||||
|
||||
await subsonicsService.loadScript()
|
||||
await giteaService.loadScript()
|
||||
await jenkinsService.loadScript()
|
||||
await raphixwebsite.loadScript()
|
||||
await cvraphix.loadScript()
|
||||
await lavalink.loadScript()
|
||||
|
||||
})
|
||||
|
||||
|
@ -19,8 +19,6 @@ settings.createWindow(async () => {
|
||||
</div>
|
||||
<div class="category">
|
||||
<p>Configuration des Tokens</p>
|
||||
<p class='user-line-displayname'>Jenkins</p>
|
||||
<input class='field' type="text" id="jenkins_token" placeholder="Token Jenkins">
|
||||
<p class='user-line-displayname'> Omega </p>
|
||||
<input class='field' type="text" id="omega_token" placeholder="Token Omega">
|
||||
<button id="st-save" class="btn green"><span> Sauvegarder</span></button>
|
||||
@ -93,11 +91,9 @@ settings.createWindow(async () => {
|
||||
const restartButton = document.getElementById("st-restart")
|
||||
const stopButton = document.getElementById("st-stop")
|
||||
const saveButton = document.getElementById("st-save")
|
||||
const jenkinsToken = document.getElementById("jenkins_token")
|
||||
const omegaToken = document.getElementById("omega_token")
|
||||
|
||||
get("SETTINGS_GET").then((settings) => {
|
||||
jenkinsToken.value = settings.jenkins_token
|
||||
omegaToken.value = settings.omega_token
|
||||
})
|
||||
|
||||
@ -111,12 +107,11 @@ settings.createWindow(async () => {
|
||||
|
||||
saveButton.addEventListener("click", () => {
|
||||
post("SETTINGS_SAVE", {
|
||||
jenkins_token: jenkinsToken.value,
|
||||
omega_token: omegaToken.value
|
||||
})
|
||||
|
||||
get("SETTINGS_GET").then((settings) => {
|
||||
jenkinsToken.value = settings.jenkins_token
|
||||
|
||||
omegaToken.value = settings.omega_token
|
||||
})
|
||||
})
|
||||
|
@ -61,10 +61,7 @@ users.createWindow(async () => {
|
||||
<input type="checkbox" id="perm_SERVERS">
|
||||
<label for="perm_SERVERS">Serveurs</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" id="perm_PIPELINES">
|
||||
<label for="perm_PIPELINES">Pipelines</label>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<input type="checkbox" id="perm_METRICS">
|
||||
<label for="perm_METRICS">Metrics</label>
|
||||
|
@ -54,7 +54,6 @@
|
||||
<script src="/javascripts/link.js"></script>
|
||||
<script src="/javascripts/service.js"></script>
|
||||
<script src="/javascripts/server.js"></script>
|
||||
<script src="/javascripts/pipeline.js"></script>
|
||||
<script src="/javascripts/filexplorer.js"></script>
|
||||
<script src="/javascripts/user.js"></script>
|
||||
<script src="/javascripts/metric.js"></script>
|
||||
|
Reference in New Issue
Block a user