-
Notifications
You must be signed in to change notification settings - Fork 2
124 lines (106 loc) · 3.61 KB
/
deploy-preview.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
name: Deploy to Server
on:
workflow_dispatch:
push:
branches:
- main
- develop
permissions:
contents: read
packages: read
deployments: write
jobs:
# First: Make sure dev build ran fine.
build-test-solution:
name: Build & Test Solution
uses: Nodsoft/workflows/.github/workflows/build-dotnet.yml@main
with:
dotnet-version: '8.0'
configuration: 'Release'
project-file: 'WoWS-Karma.sln'
# Build & Package API & Web from 'build-package-api.yml' and 'build-package-web.yml'.
build-package-api:
name: Build & Package API
needs: build-test-solution
uses: Nodsoft/workflows/.github/workflows/package-dotnet.yml@main
strategy:
matrix:
configuration: ['production', 'preview']
with:
dotnet-version: '8.0'
configuration: ${{ matrix.configuration }}
project-file: 'WowsKarma.Api/WowsKarma.Api.csproj'
artifact-name: 'wowskarma_api_${{ matrix.configuration }}'
build-package-web:
name: Build & Package Web App
needs: build-test-solution
uses: ./.github/workflows/build-package-web.yml
strategy:
matrix:
configuration: ['production', 'preview']
with:
build_configuration: ${{ matrix.configuration }}
artifact_name: 'wowskarma_app_${{ matrix.configuration }}'
deploy-preview:
name: Deploy Preview to server
environment:
name: preview
url: https://preview.wows-karma.com/
needs:
- build-package-api
- build-package-web
runs-on: ubuntu-latest
steps:
- name: Download packaged API artifacts
uses: actions/download-artifact@v4
with:
name: wowskarma_api_preview
path: ./api
- name: Download packaged Web App artifacts
uses: actions/download-artifact@v4
with:
name: wowskarma_app_preview
path: ./web
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATEKEY }}
known_hosts: '*.nodsoft.net'
- name: Add Known Hosts
run: ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
- name: Deploy with rsync
run: rsync -rvmzOE . ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.SSH_DEPLOYPATH }}
- name: Restart API service(s)
run: ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} ${{ vars.SSH_CMD_RESTART_API }}
deploy-live:
name: Deploy Live to server
if: ${{ github.ref == 'refs/heads/main' }}
environment:
name: live
url: https://wows-karma.com/
needs:
- build-package-api
- build-package-web
runs-on: ubuntu-latest
steps:
- name: Download packaged API artifacts
uses: actions/download-artifact@v4
with:
name: wowskarma_api_production
path: ./api
- name: Download packaged Web App artifacts
uses: actions/download-artifact@v4
with:
name: wowskarma_app_production
path: ./web
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATEKEY }}
known_hosts: '*.nodsoft.net'
- name: Add Known Hosts
run: ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
- name: Deploy with rsync
run: rsync -rvmzOE . ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.SSH_DEPLOYPATH }}
- name: Restart API service(s)
run: ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} ${{ vars.SSH_CMD_RESTART_API }}