Skip to content

Commit 7b45728

Browse files
Merge remote-tracking branch 'origin/Release-2024.29' into Develop/Fixes/TD-3671-Fewcourseswhichdoesnotallowselfenrolment
2 parents 545cf0c + 7cd204d commit 7b45728

File tree

221 files changed

+10653
-5124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

221 files changed

+10653
-5124
lines changed
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: Deploy DLS DEV to IIS
2+
3+
env:
4+
# set apppool and site name from IIS
5+
AppPoolName : dlsweb-dev
6+
SiteName : 'dls-dev'
7+
# set to site files. In this case, the part of the path after E:/web/
8+
SitePath : dls-dev
9+
DOTNET_INSTALL_DIR: '~/AppData/Local/Microsoft/dotnet'
10+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
11+
on:
12+
push:
13+
branches:
14+
- 'DEV'
15+
workflow_dispatch:
16+
17+
jobs:
18+
deploy-to-dev:
19+
20+
runs-on: self-hosted
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Setup .NET Core SDK 6.0
26+
uses: actions/setup-dotnet@v4
27+
with:
28+
dotnet-version: 6.0.x
29+
- name: Setup node
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: 20
33+
34+
- name: Add TechnologyEnhancedLearning as nuget package source
35+
run: |
36+
$nugetSources = dotnet nuget list source | Out-String;
37+
if($nugetSources -like "*TechnologyEnhancedLearning*")
38+
{
39+
# Update the source (in case PAT has been updated)
40+
dotnet nuget update source TechnologyEnhancedLearning --source https://pkgs.dev.azure.com/e-LfH/_packaging/LearningHubFeed/nuget/v3/index.json --username 'kevin.whittaker' --password ${{ secrets.AZURE_DEVOPS_PAT }} --store-password-in-clear-text
41+
}
42+
else
43+
{
44+
# Add the source
45+
dotnet nuget add source https://pkgs.dev.azure.com/e-LfH/_packaging/LearningHubFeed/nuget/v3/index.json --name TechnologyEnhancedLearning --username 'kevin.whittaker' --password ${{ secrets.AZURE_DEVOPS_PAT }} --store-password-in-clear-text
46+
}
47+
- name: Dotnet publish
48+
run: |
49+
dotnet publish DigitalLearningSolutions.sln -c Release -o E:/web/${{env.SitePath}}-NEW
50+
51+
- name: Copy app_offline and web config to publish folder
52+
run: |
53+
Copy-Item E:/web/Offline/app_offline.htm E:/web/${{env.SitePath}}-NEW -Recurse -Force;
54+
Copy-Item E:/web/Offline/app_offline.htm E:/web/${{env.SitePath}} -Recurse -Force;
55+
if (Test-Path -Path E:/web/${{env.SitePath}})
56+
{
57+
Remove-Item -Path 'E:/web/${{env.SitePath}}-NEW/web.config' -Force;
58+
Copy-Item E:/web/${{env.SitePath}}/web.config E:/web/${{env.SitePath}}-NEW -Recurse -Force;
59+
}
60+
if (Test-Path -Path E:/web/${{env.SitePath}}-PREVIOUS){
61+
Remove-Item -LiteralPath 'E:/web/${{env.SitePath}}-PREVIOUS' -Force -Recurse
62+
}
63+
64+
- name: Sleep for 5 seconds
65+
run: Start-Sleep -s 5
66+
67+
- name: Switch deployment and published folders restarting apppool/webapp if necessary
68+
run: |
69+
70+
Import-Module WebAdministration;
71+
$currentRetry = 1;
72+
$backupRetry = 1;
73+
$success = $false;
74+
$backupSuccess = $false;
75+
do{
76+
echo "Attempting folder rename $currentRetry"
77+
try {
78+
Rename-Item -Path 'E:/web/${{env.SitePath}}' -NewName '${{env.SitePath}}-PREVIOUS'
79+
Rename-Item -Path 'E:/web/${{env.SitePath}}-NEW' -NewName '${{env.SitePath}}'
80+
$success = $true;
81+
}
82+
catch {
83+
echo "Rename failed due to following Catch error:`n"
84+
echo $PSItem.Exception.Message
85+
echo "`n"
86+
Start-Sleep -s 2
87+
$currentRetry = $currentRetry + 1;
88+
}
89+
finally {
90+
if ($currentRetry -ge 10) {
91+
echo "Rename keeps failing; restarting AppPool/Site as last resort`n"
92+
echo "Attempting to restart AppPool`n"
93+
do{
94+
$status = Get-WebAppPoolState -name '${{env.AppPoolName}}'
95+
if ($status.Value -eq "Stopped") {
96+
start-WebAppPool ${{env.AppPoolName}}
97+
echo "AppPool restarted`n---------`n"
98+
$backupSuccess = $true;
99+
}
100+
else {
101+
if ($backupRetry -ge 10) {
102+
throw "AppPool restart keeps failing."
103+
}
104+
echo "AppPool not stopped yet; Re-attempt #$backupRetry"
105+
Start-Sleep -s 10
106+
$backupRetry = $backupRetry + 1;
107+
}
108+
}
109+
while (!$backupSuccess -and $backupRetry -le 10)
110+
$backupRetry = 1;
111+
$backupSuccess = $false;
112+
echo "Attempting to restart Website`n"
113+
do{
114+
$status = Get-WebsiteState -name '${{env.SiteName}}'
115+
if ($status.Value -eq "Stopped") {
116+
start-iissite ${{env.SiteName}}
117+
echo "Website restarted`n---------`n"
118+
$backupSuccess = $true;
119+
}
120+
else {
121+
if ($backupRetry -ge 10) {
122+
throw "Website restart keeps failing. Please look into Server"
123+
}
124+
echo "Website not stopped yet; Re-attempt #$backupRetry"
125+
Start-Sleep -s 10
126+
$backupRetry = $backupRetry + 1;
127+
}
128+
}
129+
while (!$backupSuccess -and $backupRetry -le 10)
130+
}
131+
}
132+
}
133+
while (!$success -and $currentRetry -le 10)
134+
135+
- name: Remove Offline and remove previous deployment folder
136+
run: |
137+
if (Test-Path -Path 'E:/web/${{env.SitePath}}-PREVIOUS')
138+
{
139+
Remove-Item -LiteralPath 'E:/web/${{env.SitePath}}-PREVIOUS' -Force -Recurse
140+
}
141+
Remove-Item 'E:/web/${{env.SitePath}}/app_offline.htm' -Force
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
name: Deploy DLS Production to IIS
2+
3+
env:
4+
# set apppool and site name from IIS
5+
AppPoolName : dlsweb-v2
6+
SiteName : 'v2'
7+
# set to site files. In this case, the part of the path after E:/web/
8+
SitePath : dlsweb-v2
9+
DOTNET_INSTALL_DIR: '~/AppData/Local/Microsoft/dotnet'
10+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
11+
on:
12+
workflow_dispatch:
13+
14+
jobs:
15+
deploy-to-production:
16+
17+
runs-on: self-hosted
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Setup .NET Core SDK 6.0
23+
uses: actions/setup-dotnet@v4
24+
with:
25+
dotnet-version: 6.0.x
26+
- name: Setup node
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: 20
30+
31+
- name: Add TechnologyEnhancedLearning as nuget package source
32+
run: |
33+
$nugetSources = dotnet nuget list source | Out-String;
34+
if($nugetSources -like "*TechnologyEnhancedLearning*")
35+
{
36+
# Update the source (in case PAT has been updated)
37+
dotnet nuget update source TechnologyEnhancedLearning --source https://pkgs.dev.azure.com/e-LfH/_packaging/LearningHubFeed/nuget/v3/index.json --username 'kevin.whittaker' --password ${{ secrets.AZURE_DEVOPS_PAT }} --store-password-in-clear-text
38+
}
39+
else
40+
{
41+
# Add the source
42+
dotnet nuget add source https://pkgs.dev.azure.com/e-LfH/_packaging/LearningHubFeed/nuget/v3/index.json --name TechnologyEnhancedLearning --username 'kevin.whittaker' --password ${{ secrets.AZURE_DEVOPS_PAT }} --store-password-in-clear-text
43+
}
44+
45+
- name: Dotnet publish
46+
run: |
47+
dotnet publish DigitalLearningSolutions.sln -c Release -o E:/web/${{env.SitePath}}-NEW
48+
49+
- name: Copy app_offline and web config to publish folder
50+
run: |
51+
Copy-Item E:/web/Offline/app_offline.htm E:/web/${{env.SitePath}}-NEW -Recurse -Force;
52+
Copy-Item E:/web/Offline/app_offline.htm E:/web/${{env.SitePath}} -Recurse -Force;
53+
if (Test-Path -Path E:/web/${{env.SitePath}})
54+
{
55+
Remove-Item -Path 'E:/web/${{env.SitePath}}-NEW/web.config' -Force;
56+
Copy-Item E:/web/${{env.SitePath}}/web.config E:/web/${{env.SitePath}}-NEW -Recurse -Force;
57+
}
58+
if (Test-Path -Path E:/web/${{env.SitePath}}-PREVIOUS){
59+
Remove-Item -LiteralPath 'E:/web/${{env.SitePath}}-PREVIOUS' -Force -Recurse
60+
}
61+
62+
- name: Sleep for 5 seconds
63+
run: Start-Sleep -s 5
64+
65+
- name: Switch deployment and published folders restarting apppool/webapp if necessary
66+
run: |
67+
68+
Import-Module WebAdministration;
69+
$currentRetry = 1;
70+
$backupRetry = 1;
71+
$success = $false;
72+
$backupSuccess = $false;
73+
do{
74+
echo "Attempting folder rename $currentRetry"
75+
try {
76+
Rename-Item -Path 'E:/web/${{env.SitePath}}' -NewName '${{env.SitePath}}-PREVIOUS'
77+
Rename-Item -Path 'E:/web/${{env.SitePath}}-NEW' -NewName '${{env.SitePath}}'
78+
$success = $true;
79+
}
80+
catch {
81+
echo "Rename failed due to following Catch error:`n"
82+
echo $PSItem.Exception.Message
83+
echo "`n"
84+
Start-Sleep -s 2
85+
$currentRetry = $currentRetry + 1;
86+
}
87+
finally {
88+
if ($currentRetry -ge 10) {
89+
echo "Rename keeps failing; restarting AppPool/Site as last resort`n"
90+
echo "Attempting to restart AppPool`n"
91+
do{
92+
$status = Get-WebAppPoolState -name '${{env.AppPoolName}}'
93+
if ($status.Value -eq "Stopped") {
94+
start-WebAppPool ${{env.AppPoolName}}
95+
echo "AppPool restarted`n---------`n"
96+
$backupSuccess = $true;
97+
}
98+
else {
99+
if ($backupRetry -ge 10) {
100+
throw "AppPool restart keeps failing."
101+
}
102+
echo "AppPool not stopped yet; Re-attempt #$backupRetry"
103+
Start-Sleep -s 10
104+
$backupRetry = $backupRetry + 1;
105+
}
106+
}
107+
while (!$backupSuccess -and $backupRetry -le 10)
108+
$backupRetry = 1;
109+
$backupSuccess = $false;
110+
echo "Attempting to restart Website`n"
111+
do{
112+
$status = Get-WebsiteState -name '${{env.SiteName}}'
113+
if ($status.Value -eq "Stopped") {
114+
start-iissite ${{env.SiteName}}
115+
echo "Website restarted`n---------`n"
116+
$backupSuccess = $true;
117+
}
118+
else {
119+
if ($backupRetry -ge 10) {
120+
throw "Website restart keeps failing. Please look into Server"
121+
}
122+
echo "Website not stopped yet; Re-attempt #$backupRetry"
123+
Start-Sleep -s 10
124+
$backupRetry = $backupRetry + 1;
125+
}
126+
}
127+
while (!$backupSuccess -and $backupRetry -le 10)
128+
}
129+
}
130+
}
131+
while (!$success -and $currentRetry -le 10)
132+
133+
- name: Remove Offline and remove previous deployment folder
134+
run: |
135+
Remove-Item 'E:/web/${{env.SitePath}}/app_offline.htm' -Force

0 commit comments

Comments
 (0)