-
Notifications
You must be signed in to change notification settings - Fork 29
126 lines (123 loc) · 4.52 KB
/
Deploy-Chat.yml
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
name: chat-deploy
on:
push:
branches: [ "main"]
workflow_dispatch:
jobs:
dotnet-build-api:
name: Dotnet Build api
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore src/Egroo.Server/Egroo.Server.csproj
- name: Build
run: dotnet build --no-restore src/Egroo.Server/Egroo.Server.csproj
- name: Test
run: dotnet test --no-build --verbosity normal src/Egroo.Server/Egroo.Server.csproj
docker-build-api:
name: Docker Build api
environment:
name: 'Release API'
url: "https://api.egroo.org"
needs: dotnet-build-api
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Create appsettings
run: |
echo '{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "Server='${{ secrets.REMOTE_HOST }}';Port=5432;User Id=postgres;Password='${{ secrets.REMOTE_PASSWORD }}';Database=egroo-prod;"
},
"Secrets": {
"Jwt": "${{ secrets.JWT_PROD }}"
}
}' > src/Egroo.Server/appsettings.json
- name: build docker image
run: docker build -t jihadkhawaja/mobilechat-server-prod:latest -f src/Egroo.Server/Dockerfile .
- name: save docker image
run: |
docker save -o mobilechat-server-prod.tar jihadkhawaja/mobilechat-server-prod
- name: copy tar via ssh
uses: appleboy/[email protected]
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.KEY }}
port: 22
source: "mobilechat-server-prod.tar"
target: "/home/ubuntu/images"
- name: executing remote ssh commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.KEY }}
script: |
docker load -i /home/ubuntu/images/mobilechat-server-prod.tar
rm /home/ubuntu/images/mobilechat-server-prod.tar
docker kill mobilechat-server-prod
docker system prune -f
docker run --name mobilechat-server-prod -p 49117:8080 --restart always -v public:/app/wwwroot/public -d jihadkhawaja/mobilechat-server-prod:latest
dotnet-build-wasm:
name: Dotnet Build wasm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore src/Egroo/Egroo/Egroo.csproj
- name: Build
run: dotnet build --no-restore src/Egroo/Egroo/Egroo.csproj
- name: Test
run: dotnet test --no-build --verbosity normal src/Egroo/Egroo/Egroo.csproj
docker-build-wasm:
name: Docker Build wasm
environment:
name: 'Release WEB'
url: "https://www.egroo.org"
needs: dotnet-build-wasm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: build docker image
run: docker build -t jihadkhawaja/mobilechat-wasm-prod:latest -f src/Egroo/Egroo/Dockerfile .
- name: save docker image
run: |
docker save -o mobilechat-wasm-prod.tar jihadkhawaja/mobilechat-wasm-prod
- name: copy tar via ssh
uses: appleboy/[email protected]
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.KEY }}
port: 22
source: "mobilechat-wasm-prod.tar"
target: "/home/ubuntu/images"
- name: executing remote ssh commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.KEY }}
script: |
docker load -i /home/ubuntu/images/mobilechat-wasm-prod.tar
rm /home/ubuntu/images/mobilechat-wasm-prod.tar
docker kill mobilechat-wasm-prod
docker system prune -f
docker run --name mobilechat-wasm-prod -p 49168:8080 --restart always -v public:/app/wwwroot/public -d jihadkhawaja/mobilechat-wasm-prod:latest