forked from adam/discord-bot-shtik
Compare commits
13 Commits
401a3ecbc8
...
fc73df1d63
Author | SHA1 | Date | |
---|---|---|---|
fc73df1d63 | |||
e4384a2ea0 | |||
be36c3cb55 | |||
1141118263 | |||
41172f755c | |||
bcc5389d63 | |||
660af2805e | |||
275faaacfc | |||
09f439188a | |||
246a6e2019 | |||
33f55dc790 | |||
b4b0fd155b | |||
7546612d12 |
@ -42,7 +42,7 @@ namespace vassago
|
|||||||
ProtocolInterfaces.ProtocolList.twitchs.Add(t);
|
ProtocolInterfaces.ProtocolList.twitchs.Add(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
Task.WaitAll(initTasks, cancellationToken);
|
Task.WaitAll(initTasks.ToArray(), cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task StopAsync(CancellationToken cancellationToken)
|
public Task StopAsync(CancellationToken cancellationToken)
|
||||||
|
120
Jenkinsfile
vendored
120
Jenkinsfile
vendored
@ -1,7 +1,41 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
|
environment {
|
||||||
|
linuxServiceAccount=credentials("a83b97d0-dbc6-42d9-96c9-f07a7f2dfab5")
|
||||||
|
linuxServiceAccountID="3ca1be00-3d9f-42a1-bab2-48a4d7b99fb0"
|
||||||
|
database_connectionString=credentials("7ab58922-c647-42e5-ae15-84faa0c1ee7d")
|
||||||
|
targetHost="alloces.lan"
|
||||||
|
}
|
||||||
stages {
|
stages {
|
||||||
|
|
||||||
|
stage("environment setup") { //my environment, here on the jenkins agent
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
|
||||||
|
sh """#!/bin/bash
|
||||||
|
function testcmd(){
|
||||||
|
if ! command -v \$1 2>&1 >/dev/null
|
||||||
|
then
|
||||||
|
echo "this agent doesn't have \$1"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
testcmd mktemp
|
||||||
|
testcmd curl
|
||||||
|
testcmd git
|
||||||
|
testcmd sed
|
||||||
|
testcmd ssh
|
||||||
|
testcmd ssh-keyscan
|
||||||
|
testcmd ssh-keygen
|
||||||
|
testcmd scp
|
||||||
|
testcmd dotnet
|
||||||
|
|
||||||
|
dotnet tool install dotnet-ef
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
stage('clean old'){
|
stage('clean old'){
|
||||||
steps{
|
steps{
|
||||||
sh 'rm -rf bin obj'
|
sh 'rm -rf bin obj'
|
||||||
@ -9,17 +43,89 @@ pipeline {
|
|||||||
}
|
}
|
||||||
stage('Build') {
|
stage('Build') {
|
||||||
steps {
|
steps {
|
||||||
sh 'dotnet publish vassago.csproj --configuration Release --os linux'
|
dotnetBuild(outputDirectory: "./dist", project: "vassago.csproj")
|
||||||
archiveArtifacts artifacts: 'bin/Release/net7.0/linux-x64/publish/*'
|
archiveArtifacts artifacts: 'dist/*'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Deploy'){
|
stage ('upload') {
|
||||||
when{
|
when {
|
||||||
|
//now my CI/CD is no longer continuous, it's just... automatic.
|
||||||
|
//(which is what I actually want tbh)
|
||||||
|
//but that does mean I have to put this condition in every single branch
|
||||||
branch "release"
|
branch "release"
|
||||||
}
|
}
|
||||||
steps{
|
steps{
|
||||||
|
withCredentials([sshUserPrivateKey(credentialsId: env.linuxServiceAccountID, keyFileVariable: 'PK')])
|
||||||
|
{
|
||||||
|
sh """#!/bin/bash
|
||||||
|
ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'rm -rf temp_deploy & mkdir -p temp_deploy'
|
||||||
|
scp -i \"${PK}\" -r dist ${linuxServiceAccount_USR}@${env.targetHost}:temp_deploy
|
||||||
|
"""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stage ('stop')
|
||||||
|
{
|
||||||
|
when {
|
||||||
|
branch "release"
|
||||||
|
}
|
||||||
|
steps{
|
||||||
|
withCredentials([sshUserPrivateKey(credentialsId: env.linuxServiceAccountID, keyFileVariable: 'PK')])
|
||||||
|
{
|
||||||
|
sh """#!/bin/bash
|
||||||
|
ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'systemctl --user stop vassago'
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage ('update db')
|
||||||
|
{
|
||||||
|
when {
|
||||||
|
branch "release"
|
||||||
|
}
|
||||||
|
steps{
|
||||||
|
//TODO: backup database
|
||||||
|
sh """#!/bin/bash
|
||||||
|
"""
|
||||||
|
|
||||||
|
sh """#!/bin/bash
|
||||||
|
dotnet ef database update --connection "${env.database_connectionString}"
|
||||||
|
"""
|
||||||
|
//TODO: if updating the db fails, restore the old one
|
||||||
|
sh """#!/bin/bash
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage ('replace')
|
||||||
|
{
|
||||||
|
when {
|
||||||
|
branch "release"
|
||||||
|
}
|
||||||
|
steps{
|
||||||
|
withCredentials([sshUserPrivateKey(credentialsId: env.linuxServiceAccountID, keyFileVariable: 'PK')])
|
||||||
|
{
|
||||||
|
sh """#!/bin/bash
|
||||||
|
ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'mv dist/appsettings.json appsettings.json'
|
||||||
|
ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'rm -rf dist/ && shopt -s dotglob & mv temp_deploy/* dist/'
|
||||||
|
ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'mv appsettings.json dist/appsettings.json'
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage ('spin up')
|
||||||
|
{
|
||||||
|
when {
|
||||||
|
branch "release"
|
||||||
|
}
|
||||||
|
steps{
|
||||||
|
withCredentials([sshUserPrivateKey(credentialsId: env.linuxServiceAccountID, keyFileVariable: 'PK')])
|
||||||
|
{
|
||||||
|
sh """#!/bin/bash
|
||||||
|
ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'systemctl --user start vassago'
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<NoWarn>$(NoWarn);CA2254</NoWarn>
|
<NoWarn>$(NoWarn);CA2254</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user