forked from Corona-Studio/ConnectX
-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (114 loc) · 4.3 KB
/
Copy pathdeploy.yml
File metadata and controls
132 lines (114 loc) · 4.3 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Deploy ConnectX
on:
push:
workflow_dispatch:
jobs:
publish:
strategy:
matrix:
configuration: [Relay, Server]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Init git submodule
run: |
git submodule init
git submodule update
- name: Restore the application
run: dotnet restore
- name: Build the application
run: |
cd ./ConnectX.${{ matrix.configuration }}
dotnet publish -f net9.0 -c Release -r linux-x64 --self-contained false /p:PublishSingleFile=true
- name: Remove extra files
run: |
cd ./ConnectX.${{ matrix.configuration }}/bin/Release/net9.0/linux-x64/publish/
rm -f *.pdb
rm -f *.json
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.configuration }}-Release-linux-x64
path: ./ConnectX.${{ matrix.configuration }}/bin/Release/net9.0/linux-x64/publish/
deploy-server:
needs: publish
strategy:
matrix:
server: [hangzhou]
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: Server-Release-linux-x64
path: ./deploy-package
- name: Remove excluded files
run: |
find ./deploy-package -name "appsettings*.json" -delete
- name: Stop remote service
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets[format('Server_{0}_SSH_HOST', matrix.server)] }}
username: ${{ secrets[format('Server_{0}_SSH_USERNAME', matrix.server)] }}
password: ${{ secrets[format('Server_{0}_SSH_KEY', matrix.server)] }}
script: sudo supervisorctl stop connectx-Server-service
- name: Deploy via SFTP
uses: wlixcc/SFTP-Deploy-Action@v1.2.5
with:
server: ${{ secrets[format('Server_{0}_SSH_HOST', matrix.server)] }}
username: ${{ secrets[format('Server_{0}_SSH_USERNAME', matrix.server)] }}
password: ${{ secrets[format('Server_{0}_SSH_KEY', matrix.server)] }}
local_path: './deploy-package/*'
remote_path: '/www/connectx/Server'
- name: Start remote service
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets[format('Server_{0}_SSH_HOST', matrix.server)] }}
username: ${{ secrets[format('Server_{0}_SSH_USERNAME', matrix.server)] }}
password: ${{ secrets[format('Server_{0}_SSH_KEY', matrix.server)] }}
script: sudo supervisorctl start connectx-Server-service
deploy-relay:
needs: deploy-server
strategy:
fail-fast: false
matrix:
server: [hangzhou, shiyan]
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: Relay-Release-linux-x64
path: ./deploy-package
- name: Remove excluded files
run: |
find ./deploy-package -name "appsettings*.json" -delete
- name: Stop remote service
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets[format('Relay_{0}_SSH_HOST', matrix.server)] }}
username: ${{ secrets[format('Relay_{0}_SSH_USERNAME', matrix.server)] }}
password: ${{ secrets[format('Relay_{0}_SSH_KEY', matrix.server)] }}
script: sudo supervisorctl stop connectx-Relay-service
- name: Deploy via SFTP
uses: wlixcc/SFTP-Deploy-Action@v1.2.5
with:
server: ${{ secrets[format('Relay_{0}_SSH_HOST', matrix.server)] }}
username: ${{ secrets[format('Relay_{0}_SSH_USERNAME', matrix.server)] }}
password: ${{ secrets[format('Relay_{0}_SSH_KEY', matrix.server)] }}
local_path: './deploy-package/*'
remote_path: '/www/connectx/Relay'
- name: Start remote service
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets[format('Relay_{0}_SSH_HOST', matrix.server)] }}
username: ${{ secrets[format('Relay_{0}_SSH_USERNAME', matrix.server)] }}
password: ${{ secrets[format('Relay_{0}_SSH_KEY', matrix.server)] }}
script: sudo supervisorctl start connectx-Relay-service