55 types : [published]
66
77jobs :
8- build :
8+ buildlinux :
99 name : " Release"
1010 env :
1111 ASPNETCORE_ENVIRONMENT : " Production"
@@ -52,80 +52,87 @@ jobs:
5252 - name : Publish API
5353 if : ${{ github.event.release.prerelease == false }}
5454 run : dotnet publish "MobileConfiguration\MobileConfiguration.csproj" --configuration Release --output publishOutput -r win-x64 --self-contained
55- - name : Create Zip package 🐙
56- id : package
57- uses : OctopusDeploy/create-zip-package-action@v3
58- with :
59- package_id : MobileConfiguration
60- version : ${{ steps.get_version.outputs.VERSION }}
61- base_path : /home/runner/work/MobileConfiguration/MobileConfiguration/publishOutput
62- files : " **/*"
63- output_folder : /home/runner/work/MobileConfiguration/MobileConfiguration
64-
65- - name : Push a package to Octopus Deploy 🐙
66- uses : OctopusDeploy/push-package-action@v3
67- with :
68- api_key : ${{ secrets.OCTOPUS_APIKEY }}
69- server : ${{ secrets.OCTOPUS_URL }}
70- space : ${{ secrets.OCTOPUS_SPACE }}
71- packages : ${{ steps.package.outputs.package_file_path }}
7255
73- - name : Get Release
74- if : ${{ github.event.release.prerelease == false }}
75- id : getrelease
76- uses : octokit/request-action@v2.0.17
77- with :
78- route : GET /repos/StuartFerguson/MobileConfiguration/releases/tags/${{ steps.get_version.outputs.VERSION }}
79- env :
80- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
56+ - name : Build Release Package
57+ run : |
58+ cd /home/runner/work/MobileConfiguration/MobileConfiguration/publishOutput
59+ zip -r ../mobileconfiguration.zip ./*
8160
82- - name : Build Release Notes
83- if : ${{ github.event.release.prerelease == false }}
84- id : buildreleasenotes
85- uses : gr2m/get-json-paths-action@v1.0.4
61+ - name : Upload the artifact
62+ uses : actions/upload-artifact@v3
8663 with :
87- json : ${{ steps.getrelease.outputs.data }}
88- releasenote : " body "
64+ name : mobileconfiguration
65+ path : mobileconfiguration.zip
8966
90- - name : Create a release in Octopus Deploy 🐙
91- uses : OctopusDeploy/create-release-action@v3
92- id : " create_release"
93- with :
94- api_key : ${{ secrets.OCTOPUS_APIKEY }}
95- server : ${{ secrets.OCTOPUS_URL }}
96- space : ${{ secrets.OCTOPUS_SPACE }}
97- project : " Mobile Configuration"
98- package_version : ${{ steps.get_version.outputs.VERSION }}
99- release_notes : ${{ steps.buildreleasenotes.outputs.releasenote }}
100- release_number : ${{ steps.get_version.outputs.VERSION }}
101- ignore_existing : true
102- channel : " Default"
103-
104- - name : Deploy a release in Octopus Deploy 🐙
105- uses : OctopusDeploy/deploy-release-action@v3
106- id : " deploy_release"
107- with :
108- api_key : ${{ secrets.OCTOPUS_APIKEY }}
109- server : ${{ secrets.OCTOPUS_URL }}
110- space : ${{ secrets.OCTOPUS_SPACE }}
111- project : " Mobile Configuration"
112- release_number : ${{steps.create_release.outputs.release_number}}
113- environments : |
114- Staging
115-
116- - name : Await task in Octopus Deploy 🐙
117- uses : OctopusDeploy/await-task-action@v3
118- with :
119- api_key : ${{ secrets.OCTOPUS_APIKEY }}
120- server : ${{ secrets.OCTOPUS_URL }}
121- space : ${{ secrets.OCTOPUS_SPACE }}
122- timeout_after : 300
123- polling_interval : 30
124- server_task_id : ${{ fromJson(steps.deploy_release.outputs.server_tasks)[0].serverTaskId }}
12567
12668 # - name: Build and Publish Nuget Packages
12769 # if: ${{ github.event.release.prerelease == false }}
12870 # run: |
12971 # dotnet pack "TransactionProcessor.Client\TransactionProcessor.Client.csproj" /p:PackageVersion=${{ steps.get_version.outputs.VERSION }} --output Nugets
13072 # dotnet nuget push Nugets/TransactionProcessor.Client.${{ steps.get_version.outputs.VERSION }}.nupkg --api-key ${{ secrets.MYGET_APIKEY }} --source https://www.myget.org/F/transactionprocessing/api/v2/package
131-
73+
74+ deploystaging :
75+ runs-on : stagingserver
76+ needs : buildlinux
77+ environment : staging
78+ name : " Deploy to Staging"
79+
80+ steps :
81+ - name : Download the artifact
82+ uses : actions/download-artifact@v3
83+ with :
84+ name : mobileconfiguration
85+
86+ - name : Remove existing Windows service
87+ run : |
88+ $serviceName = "Transaction Processing - Mobile Configuration"
89+ # Check if the service exists
90+ if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) {
91+ Stop-Service -Name $serviceName
92+ sc.exe delete $serviceName
93+ }
94+
95+ - name : Unzip the files
96+ run : |
97+ Expand-Archive -Path mobileconfiguration.zip -DestinationPath "C:\txnproc\transactionprocessing\mobileconfiguration" -Force
98+
99+ - name : Install as a Windows service
100+ run : |
101+ $serviceName = "Transaction Processing - Mobile Configuration"
102+ $servicePath = "C:\txnproc\transactionprocessing\mobileconfiguration\MobileConfiguration.exe"
103+
104+ New-Service -Name $serviceName -BinaryPathName $servicePath -Description "Transaction Processing - Mobile Configuration" -DisplayName "Transaction Processing - Mobile Configuration" -StartupType Automatic
105+ Start-Service -Name $serviceName
106+
107+ deployproduction :
108+ runs-on : productionserver
109+ needs : [buildlinux, deploystaging]
110+ environment : production
111+ name : " Deploy to Production"
112+
113+ steps :
114+ - name : Download the artifact
115+ uses : actions/download-artifact@v3
116+ with :
117+ name : mobileconfiguration
118+
119+ - name : Remove existing Windows service
120+ run : |
121+ $serviceName = "Transaction Processing - Mobile Configuration"
122+ # Check if the service exists
123+ if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) {
124+ Stop-Service -Name $serviceName
125+ sc.exe delete $serviceName
126+ }
127+
128+ - name : Unzip the files
129+ run : |
130+ Expand-Archive -Path mobileconfiguration.zip -DestinationPath "C:\txnproc\transactionprocessing\mobileconfiguration" -Force
131+
132+ - name : Install as a Windows service
133+ run : |
134+ $serviceName = "Transaction Processing - Mobile Configuration"
135+ $servicePath = "C:\txnproc\transactionprocessing\mobileconfiguration\MobileConfiguration.exe"
136+
137+ New-Service -Name $serviceName -BinaryPathName $servicePath -Description "Transaction Processing - Mobile Configuration" -DisplayName "Transaction Processing - Mobile Configuration" -StartupType Automatic
138+ Start-Service -Name $serviceName
0 commit comments