Skip to content

Commit dd924dc

Browse files
authored
Merge pull request #2560 from TechnologyEnhancedLearning/Release-DLS-2023.26
Release DLS 2023.26 merge to production
2 parents 9e07434 + e002c48 commit dd924dc

File tree

120 files changed

+4776
-466
lines changed

Some content is hidden

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

120 files changed

+4776
-466
lines changed
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
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+
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;
40+
}
41+
42+
- name: Dotnet publish
43+
run: |
44+
dotnet publish DigitalLearningSolutions.sln -c Release -o E:/web/${{env.SitePath}}-NEW
45+
46+
- name: Copy app_offline and web config to publish folder
47+
run: |
48+
Copy-Item E:/web/Offline/app_offline.htm E:/web/${{env.SitePath}}-NEW -Recurse -Force;
49+
Copy-Item E:/web/Offline/app_offline.htm E:/web/${{env.SitePath}} -Recurse -Force;
50+
if (Test-Path -Path E:/web/${{env.SitePath}})
51+
{
52+
Remove-Item -Path 'E:/web/${{env.SitePath}}-NEW/web.config' -Force;
53+
Copy-Item E:/web/${{env.SitePath}}/web.config E:/web/${{env.SitePath}}-NEW -Recurse -Force;
54+
}
55+
if (Test-Path -Path E:/web/${{env.SitePath}}-PREVIOUS){
56+
Remove-Item -LiteralPath 'E:/web/${{env.SitePath}}-PREVIOUS' -Force -Recurse
57+
}
58+
59+
- name: Sleep for 5 seconds
60+
run: Start-Sleep -s 5
61+
62+
- name: Switch deployment and published folders restarting apppool/webapp if necessary
63+
run: |
64+
65+
Import-Module WebAdministration;
66+
$currentRetry = 1;
67+
$backupRetry = 1;
68+
$success = $false;
69+
$backupSuccess = $false;
70+
do{
71+
echo "Attempting folder rename $currentRetry"
72+
try {
73+
Rename-Item -Path 'E:/web/${{env.SitePath}}' -NewName '${{env.SitePath}}-PREVIOUS'
74+
Rename-Item -Path 'E:/web/${{env.SitePath}}-NEW' -NewName '${{env.SitePath}}'
75+
$success = $true;
76+
}
77+
catch {
78+
echo "Rename failed due to following Catch error:`n"
79+
echo $PSItem.Exception.Message
80+
echo "`n"
81+
Start-Sleep -s 2
82+
$currentRetry = $currentRetry + 1;
83+
}
84+
finally {
85+
if ($currentRetry -ge 10) {
86+
echo "Rename keeps failing; restarting AppPool/Site as last resort`n"
87+
echo "Attempting to restart AppPool`n"
88+
do{
89+
$status = Get-WebAppPoolState -name '${{env.AppPoolName}}'
90+
if ($status.Value -eq "Stopped") {
91+
start-WebAppPool ${{env.AppPoolName}}
92+
echo "AppPool restarted`n---------`n"
93+
$backupSuccess = $true;
94+
}
95+
else {
96+
if ($backupRetry -ge 10) {
97+
throw "AppPool restart keeps failing."
98+
}
99+
echo "AppPool not stopped yet; Re-attempt #$backupRetry"
100+
Start-Sleep -s 10
101+
$backupRetry = $backupRetry + 1;
102+
}
103+
}
104+
while (!$backupSuccess -and $backupRetry -le 10)
105+
$backupRetry = 1;
106+
$backupSuccess = $false;
107+
echo "Attempting to restart Website`n"
108+
do{
109+
$status = Get-WebsiteState -name '${{env.SiteName}}'
110+
if ($status.Value -eq "Stopped") {
111+
start-iissite ${{env.SiteName}}
112+
echo "Website restarted`n---------`n"
113+
$backupSuccess = $true;
114+
}
115+
else {
116+
if ($backupRetry -ge 10) {
117+
throw "Website restart keeps failing. Please look into Server"
118+
}
119+
echo "Website not stopped yet; Re-attempt #$backupRetry"
120+
Start-Sleep -s 10
121+
$backupRetry = $backupRetry + 1;
122+
}
123+
}
124+
while (!$backupSuccess -and $backupRetry -le 10)
125+
}
126+
}
127+
}
128+
while (!$success -and $currentRetry -le 10)
129+
130+
- name: Remove Offline and remove previous deployment folder
131+
run: |
132+
if (Test-Path -Path 'E:/web/${{env.SitePath}}-PREVIOUS')
133+
{
134+
Remove-Item -LiteralPath 'E:/web/${{env.SitePath}}-PREVIOUS' -Force -Recurse
135+
}
136+
Remove-Item 'E:/web/${{env.SitePath}}/app_offline.htm' -Force
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
name: Deploy DLS UAT to IIS
2+
3+
env:
4+
# set apppool and site name from IIS
5+
AppPoolName : dlsweb-uar
6+
SiteName : 'dls-uar-uat'
7+
# set to site files. In this case, the part of the path after E:/web/
8+
SitePath : dls-uat
9+
DOTNET_INSTALL_DIR: '~/AppData/Local/Microsoft/dotnet'
10+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
11+
on:
12+
push:
13+
branches:
14+
- 'UAT'
15+
workflow_dispatch:
16+
17+
jobs:
18+
deploy-to-uat:
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+
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;
40+
}
41+
42+
- name: Dotnet publish
43+
run: |
44+
dotnet publish DigitalLearningSolutions.sln -c Release -o E:/web/${{env.SitePath}}-NEW
45+
46+
- name: Copy app_offline and web config to publish folder
47+
run: |
48+
Copy-Item E:/web/Offline/app_offline.htm E:/web/${{env.SitePath}}-NEW -Recurse -Force;
49+
Copy-Item E:/web/Offline/app_offline.htm E:/web/${{env.SitePath}} -Recurse -Force;
50+
if (Test-Path -Path E:/web/${{env.SitePath}})
51+
{
52+
Remove-Item -Path 'E:/web/${{env.SitePath}}-NEW/web.config' -Force;
53+
Copy-Item E:/web/${{env.SitePath}}/web.config E:/web/${{env.SitePath}}-NEW -Recurse -Force;
54+
}
55+
if (Test-Path -Path E:/web/${{env.SitePath}}-PREVIOUS){
56+
Remove-Item -LiteralPath 'E:/web/${{env.SitePath}}-PREVIOUS' -Force -Recurse
57+
}
58+
59+
- name: Sleep for 5 seconds
60+
run: Start-Sleep -s 5
61+
62+
- name: Switch deployment and published folders restarting apppool/webapp if necessary
63+
run: |
64+
65+
Import-Module WebAdministration;
66+
$currentRetry = 1;
67+
$backupRetry = 1;
68+
$success = $false;
69+
$backupSuccess = $false;
70+
do{
71+
echo "Attempting folder rename $currentRetry"
72+
try {
73+
Rename-Item -Path 'E:/web/${{env.SitePath}}' -NewName '${{env.SitePath}}-PREVIOUS'
74+
Rename-Item -Path 'E:/web/${{env.SitePath}}-NEW' -NewName '${{env.SitePath}}'
75+
$success = $true;
76+
}
77+
catch {
78+
echo "Rename failed due to following Catch error:`n"
79+
echo $PSItem.Exception.Message
80+
echo "`n"
81+
Start-Sleep -s 2
82+
$currentRetry = $currentRetry + 1;
83+
}
84+
finally {
85+
if ($currentRetry -ge 10) {
86+
echo "Rename keeps failing; restarting AppPool/Site as last resort`n"
87+
echo "Attempting to restart AppPool`n"
88+
do{
89+
$status = Get-WebAppPoolState -name '${{env.AppPoolName}}'
90+
if ($status.Value -eq "Stopped") {
91+
start-WebAppPool ${{env.AppPoolName}}
92+
echo "AppPool restarted`n---------`n"
93+
$backupSuccess = $true;
94+
}
95+
else {
96+
if ($backupRetry -ge 10) {
97+
throw "AppPool restart keeps failing."
98+
}
99+
echo "AppPool not stopped yet; Re-attempt #$backupRetry"
100+
Start-Sleep -s 10
101+
$backupRetry = $backupRetry + 1;
102+
}
103+
}
104+
while (!$backupSuccess -and $backupRetry -le 10)
105+
$backupRetry = 1;
106+
$backupSuccess = $false;
107+
echo "Attempting to restart Website`n"
108+
do{
109+
$status = Get-WebsiteState -name '${{env.SiteName}}'
110+
if ($status.Value -eq "Stopped") {
111+
start-iissite ${{env.SiteName}}
112+
echo "Website restarted`n---------`n"
113+
$backupSuccess = $true;
114+
}
115+
else {
116+
if ($backupRetry -ge 10) {
117+
throw "Website restart keeps failing. Please look into Server"
118+
}
119+
echo "Website not stopped yet; Re-attempt #$backupRetry"
120+
Start-Sleep -s 10
121+
$backupRetry = $backupRetry + 1;
122+
}
123+
}
124+
while (!$backupSuccess -and $backupRetry -le 10)
125+
}
126+
}
127+
}
128+
while (!$success -and $currentRetry -le 10)
129+
130+
- name: Remove Offline and remove previous deployment folder
131+
run: |
132+
if (Test-Path -Path 'E:/web/${{env.SitePath}}-PREVIOUS')
133+
{
134+
Remove-Item -LiteralPath 'E:/web/${{env.SitePath}}-PREVIOUS' -Force -Recurse
135+
}
136+
Remove-Item 'E:/web/${{env.SitePath}}/app_offline.htm' -Force

.github/workflows/continuous-integration-workflow.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
name: Continuous Integration
2-
on: [push]
2+
on:
3+
push:
4+
branches-ignore:
5+
- 'UAT'
6+
- 'DEV'
7+
38
jobs:
49
build:
510
name: Build and test
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
namespace DigitalLearningSolutions.Data.Migrations
2+
{
3+
using FluentMigrator;
4+
5+
[Migration(202311301431)]
6+
public class CreateAssessmentResultsSP : Migration
7+
{
8+
public override void Up()
9+
{
10+
Execute.Sql(Properties.Resources.TD_3187_CreateGetCandidateAssessmentResultsById_SP);
11+
Execute.Sql(Properties.Resources.TD_3187_CreateGetAssessmentResultsByDelegate_SP);
12+
}
13+
14+
public override void Down()
15+
{
16+
Execute.Sql(@$"DROP PROCEDURE [dbo].[GetCandidateAssessmentResultsById]");
17+
Execute.Sql(@$"DROP PROCEDURE [dbo].[GetAssessmentResultsByDelegate]");
18+
}
19+
}
20+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using FluentMigrator;
2+
3+
namespace DigitalLearningSolutions.Data.Migrations
4+
{
5+
[Migration(202401161703)]
6+
public class UpdateCandidateAssessments_SetDateMinValueToNull : Migration
7+
{
8+
public override void Up()
9+
{
10+
Execute.Sql(
11+
@$"UPDATE CandidateAssessments SET CompleteByDate = NULL
12+
WHERE CompleteByDate = '1900-01-01 00:00:00.000';"
13+
);
14+
}
15+
16+
public override void Down()
17+
{
18+
}
19+
}
20+
}
21+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
namespace DigitalLearningSolutions.Data.Migrations
2+
{
3+
using FluentMigrator;
4+
5+
[Migration(202402271112)]
6+
public class Alter_uspCreateProgressRecordWithCompleteWithinMonthsSPs : Migration
7+
{
8+
public override void Up()
9+
{
10+
Execute.Sql(Properties.Resources.TD_3623_Alter_uspCreateProgressRecordWithCompleteWithinMonthsSPs_Up);
11+
12+
Execute.Sql(
13+
@$"UPDATE Progress SET EnrollmentMethodID = 4
14+
WHERE EnrollmentMethodID = 0 OR EnrollmentMethodID > 4;"
15+
);
16+
}
17+
public override void Down()
18+
{
19+
Execute.Sql(Properties.Resources.TD_3623_Alter_uspCreateProgressRecordWithCompleteWithinMonthsSPs_Down);
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)