-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (73 loc) · 3.33 KB
/
main.yml
File metadata and controls
90 lines (73 loc) · 3.33 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
name: Publish and Deploy .NET Core Application
on:
workflow_dispatch: # Allows manual triggering of the workflow
jobs:
build:
runs-on: ubuntu-latest
name: "Create the Release Package"
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Restore dependencies
run: dotnet restore TransactionProcessor.HealthChecksUI/TransactionProcessor.HealthChecksUI.sln
- name: Build the application
run: dotnet build TransactionProcessor.HealthChecksUI/TransactionProcessor.HealthChecksUI.sln --configuration Release --no-restore
- name: Publish the application
run: dotnet publish "TransactionProcessor.HealthChecksUI/TransactionProcessor.HealthChecksUI/TransactionProcessor.HealthChecksUI.csproj" --configuration Release --output TransactionProcessor.HealthChecksUI/publishOutput -r win-x64 --self-contained
- name: Zip the published files
run: |
cd ./TransactionProcessor.HealthChecksUI/publishOutput
zip -r ../../healthchecksui.zip ./*
- name: Upload the artifact
uses: actions/upload-artifact@v3
with:
name: healthchecksui
path: healthchecksui.zip
deploystaging:
runs-on: stagingserver
needs: build
environment: staging
name: "Deploy to Staging"
steps:
- name: Download the artifact
uses: actions/download-artifact@v3
with:
name: healthchecksui
- name: Unzip the files
run: |
Expand-Archive -Path healthchecksui.zip -DestinationPath "C:\testrelease\healchecksui" -Force
- name: Install as a Windows service
run: |
$serviceName = "Test Health UI"
$servicePath = "C:\testrelease\healchecksui\TransactionProcessor.HealthChecksUI.exe"
# Check if the service exists
if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) {
Stop-Service -Name $serviceName
sc.exe delete $serviceName
}
New-Service -Name $serviceName -BinaryPathName $servicePath -Description "TransactionProcessor.HealthChecksUI" -DisplayName "TransactionProcessor.HealthChecksUI Test" -StartupType Automatic
Start-Service -Name $serviceName
deployproduction:
runs-on: productionserver
needs: [build, deploystaging]
environment: production
name: "Deploy to Production"
steps:
- name: Download the artifact
uses: actions/download-artifact@v3
with:
name: healthchecksui
- name: Unzip the files
run: |
Expand-Archive -Path healthchecksui.zip -DestinationPath "C:\testrelease\healchecksui" -Force
- name: Install as a Windows service
run: |
$serviceName = "Test Health UI"
$servicePath = "C:\testrelease\healchecksui\TransactionProcessor.HealthChecksUI.exe"
# Check if the service exists
if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) {
Stop-Service -Name $serviceName
sc.exe delete $serviceName
}
New-Service -Name $serviceName -BinaryPathName $servicePath -Description "TransactionProcessor.HealthChecksUI" -DisplayName "TransactionProcessor.HealthChecksUI Test" -StartupType Automatic
Start-Service -Name $serviceName