forked from ko4life-net/ko
-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (73 loc) · 2.59 KB
/
deploy.yml
File metadata and controls
81 lines (73 loc) · 2.59 KB
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
72
73
74
75
76
77
78
79
80
81
name: Deploy
on:
workflow_dispatch:
inputs:
commit_hash:
description: commit hash to build and deploy
required: true
jobs:
Build:
runs-on: windows-2022
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.commit_hash }}
- name: Install Dependencies
shell: cmd
run: |
cd src
git clone --depth=1 https://github.com/ko4life-net/ko-vendor.git vendor
pip install paramiko
- name: Build Server
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat"
cd src
msbuild Server.sln -t:Clean -t:Build -p:Configuration=Release /m
- name: Upload files
shell: python
env:
KO_SERVER_PK: ${{ secrets.KO_SERVER_PK }}
KO_SERVER_USERNAME: ${{ secrets.KO_SERVER_USERNAME }}
KO_SERVER_HOSTNAME: ${{ secrets.KO_SERVER_HOSTNAME }}
run: |
import os, paramiko
pk = os.getenv('KO_SERVER_PK')
username = os.getenv('KO_SERVER_USERNAME')
hostname = os.getenv('KO_SERVER_HOSTNAME')
with open('pk.pem', 'w') as f: f.write(pk)
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(hostname=hostname, username=username, key_filename='pk.pem')
sftp = client.open_sftp()
source = 'src/build/x86-Release'
for item in os.listdir(source):
if os.path.isfile(os.path.join(source, item)):
sftp.put(os.path.join(source, item), f'Desktop/ftp/build/Release/{item}')
sftp.close()
client.close()
os.remove('pk.pem')
Deploy:
needs: Build
runs-on: ubuntu-20.04
timeout-minutes: 15
steps:
- name: Restart Server
uses: appleboy/ssh-action@v0.1.7
with:
host: ${{ secrets.KO_SERVER_HOSTNAME }}
username: ${{ secrets.KO_SERVER_USERNAME }}
key: ${{ secrets.KO_SERVER_PK }}
script: |
$servers = @("LoginServerNSSM", "AujardNSSM", "EbenezerNSSM", "AIServerNSSM")
foreach ($server in $servers) {
Stop-Service -Name $server
}
Start-Sleep -s 60
Copy-Item -Path "C:\Users\ko4life\Desktop\ftp\build\Release\*" -Destination "C:\Users\ko4life\server" -Recurse
[array]::Reverse($servers)
foreach ($server in $servers) {
Start-Service -Name $server
Start-Sleep -s 15
}