Skip to content

Commit eafe61b

Browse files
authored
Merge pull request #1377 from TechnologyEnhancedLearning/Develop/Feature/TD-6116-CI-Nuget
TD-6116 Workflow and Nuget update
2 parents 72d5550 + cdd53c5 commit eafe61b

File tree

4 files changed

+165
-2
lines changed

4 files changed

+165
-2
lines changed

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

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ on: [push]
33
env:
44
BuildParameters.RestoreBuildProjects: '**/*.csproj'
55
BuildParameters.TestProjects: '**/*[Tt]ests/*.csproj'
6+
7+
# Nuget Feed Credentials
8+
TEL_GITHUB_DEVOPS_USERNAME: ${{ secrets.TEL_GITHUB_DEVOPS_USERNAME }}
9+
TEL_GITHUB_PACKAGE_READ_PAT: ${{ secrets.TEL_GITHUB_PACKAGE_READ_PAT }}
10+
TEL_AZURE_DEVOPS_USERNAME: ${{ secrets.TEL_AZURE_DEVOPS_USERNAME }}
11+
TEL_AZURE_DEVOPS_PAT: ${{ secrets.AZURE_DEVOPS_PAT }}
612
jobs:
713
build:
814
name: Build and test
@@ -15,10 +21,45 @@ jobs:
1521
with:
1622
dotnet-version: 8.0.x
1723

18-
- name: Add Azure artifact
24+
# Todo: remove check once all pipeline work and have the file
25+
- name: Check if nuget.config.cicd exists
26+
id: check_nuget_cicd
27+
run: |
28+
if (Test-Path "nuget.config.cicd") {
29+
echo "exists=true" >> $env:GITHUB_OUTPUT
30+
echo "nuget.config.cicd exists"
31+
} else {
32+
echo "exists=false" >> $env:GITHUB_OUTPUT
33+
echo "nuget.config.cicd doesnt exist"
34+
}
35+
shell: pwsh
36+
37+
# Remove local nuget.config (Should be gitignored) and create nuget.config from nuget.config.cicd
38+
# Todo: remove if once all pipeline work and have the file
39+
- name: Setup NuGet with CICD config
40+
if: steps.check_nuget_cicd.outputs.exists == 'true'
41+
run: |
42+
if (Test-Path "nuget.config") { Remove-Item "nuget.config" }
43+
Copy-Item "nuget.config.cicd" "nuget.config"
44+
shell: pwsh
45+
46+
# Replace env values with github secrets
47+
- name: Replace environment variables in nuget config
48+
if: steps.check_nuget_cicd.outputs.exists == 'true'
49+
run: |
50+
(Get-Content nuget.config) -replace '%TEL_GITHUB_DEVOPS_USERNAME%', $env:TEL_GITHUB_DEVOPS_USERNAME | Set-Content nuget.config
51+
(Get-Content nuget.config) -replace '%TEL_GITHUB_PACKAGE_READ_PAT%', $env:TEL_GITHUB_PACKAGE_READ_PAT | Set-Content nuget.config
52+
(Get-Content nuget.config) -replace '%TEL_AZURE_DEVOPS_USERNAME%', $env:TEL_AZURE_DEVOPS_USERNAME | Set-Content nuget.config
53+
(Get-Content nuget.config) -replace '%TEL_AZURE_DEVOPS_PAT%', $env:TEL_AZURE_DEVOPS_PAT | Set-Content nuget.config
54+
shell: pwsh
55+
56+
# Todo: remove fallback once all pipeline work and have the file
57+
- name: Setup NuGet with Azure DevOps (fallback)
58+
if: steps.check_nuget_cicd.outputs.exists == 'false'
1959
run: |
2060
dotnet nuget remove source LearningHubFeed || true
21-
dotnet nuget add source 'https://pkgs.dev.azure.com/e-LfH/_packaging/LearningHubFeed/nuget/v3/index.json' --name 'LearningHubFeed' --username 'kevin.whittaker' --password ${{ secrets.AZURE_DEVOPS_PAT }} --store-password-in-clear-text
61+
dotnet nuget add source 'https://pkgs.dev.azure.com/e-LfH/_packaging/LearningHubFeed/nuget/v3/index.json' --name 'LearningHubFeed' --username 'kevin.whittaker' --password ${{ secrets.AZURE_DEVOPS_PAT }} --store-password-in-clear-text
62+
2263
2364
- name: Use Node 14
2465
uses: actions/setup-node@v4

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,9 @@ obj
5656
/AdminUI/LearningHub.Nhs.AdminUI/web.config
5757
/LearningHub.Nhs.WebUI/web.config
5858
/WebAPI/LearningHub.Nhs.API/web.config
59+
/nuget.config
60+
/LearningHub.Nhs.WebUI.slnLaunch.user
61+
/LearningHub.Nhs.WebUI.BlazorClient/LearningHub.Nhs.WebUI.BlazorClient.csproj.user
62+
/LearningHub.Nhs.WebUI.BlazorClient/wwwroot/appsettings.Development.json
63+
/LearningHub.Nhs.WebUI.BlazorClient/Properties/launchSettings.json
64+
/.github/workflows/test.yml

nuget.config.cicd

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<!-- using environmental variables:
4+
* for cicd sed replace environmental variables
5+
-->
6+
<packageSources>
7+
<!--Clean and just use these sources-->
8+
<clear />
9+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
10+
<add key="TELGitNugetFeed" value="https://nuget.pkg.github.com/TechnologyEnhancedLearning/index.json" />
11+
<add key="TELAzureLearningHubNugetFeed" value="https://pkgs.dev.azure.com/e-LfH/_packaging/LearningHubFeed/nuget/v3/index.json" />
12+
</packageSources>
13+
14+
<packageSourceCredentials>
15+
<TELGitNugetFeed>
16+
<add key="Username" value="%TEL_GITHUB_DEVOPS_USERNAME%" />
17+
<!--cleartext for benefit of github actions-->
18+
<add key="ClearTextPassword" value="%TEL_GITHUB_PACKAGE_READ_PAT%" />
19+
</TELGitNugetFeed>
20+
21+
<TELAzureLearningHubNugetFeed>
22+
<add key="Username" value="%TEL_AZURE_DEVOPS_USERNAME%" />
23+
<!--cleartext for benefit of github actions-->
24+
<add key="ClearTextPassword" value="%TEL_AZURE_DEVOPS_PAT%" />
25+
</TELAzureLearningHubNugetFeed>
26+
</packageSourceCredentials>
27+
28+
<!--Use local package first if not found use remote-->
29+
<!--<packageSource key="TELLocalNugetFeed">
30+
<package pattern="*" />
31+
</packageSource>-->
32+
33+
<packageSourceMapping>
34+
<packageSource key="TELGitNugetFeed">
35+
<package pattern="TELBlazor.*" />
36+
<package pattern="NHSETELViewComponents" />
37+
<!-- Best practice to only apply all to one source but we may want to enable it for convenience (and we do duplicate some packages across both sources) -->
38+
<!-- <package pattern="*" /> -->
39+
</packageSource>
40+
41+
<packageSource key="TELAzureLearningHubNugetFeed">
42+
<package pattern="LearningHub.Nhs.*" />
43+
<package pattern="elfhHub.Nhs.*" />
44+
<package pattern="GDS.MultiPageFormData" />
45+
<package pattern="NHSUKSearchSortFilterPaginate" />
46+
<package pattern="NHSUKViewComponents.Web" />
47+
<package pattern="UK.NHS.CookieBanner" />
48+
<!-- Best practice to only apply all to one source but we may want to enable it for convenience (and we do duplicate some packages across both sources) -->
49+
<!-- <package pattern="*" /> -->
50+
</packageSource>
51+
52+
<!--Check official nuget last-->
53+
<packageSource key="nuget.org">
54+
<package pattern="*" />
55+
</packageSource>
56+
</packageSourceMapping>
57+
</configuration>

nuget.config.template

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<!-- using environmental variables:
4+
* for cicd sed replace environmental variables
5+
-->
6+
<packageSources>
7+
<!--Clean and just use these sources-->
8+
<clear />
9+
<!--Local at the top so can override remote feeds-->
10+
<!--<add key="TELLocalNugetFeed" value="%TEL_LOCAL_FEED%" />-->
11+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
12+
<add key="TELGitNugetFeed" value="https://nuget.pkg.github.com/TechnologyEnhancedLearning/index.json" />
13+
<add key="TELAzureLearningHubNugetFeed" value="https://pkgs.dev.azure.com/e-LfH/_packaging/LearningHubFeed/nuget/v3/index.json" />
14+
</packageSources>
15+
16+
<packageSourceCredentials>
17+
<TELGitNugetFeed>
18+
<add key="Username" value="%TEL_GITHUB_DEVOPS_USERNAME%" />
19+
<!--cleartext for benefit of github actions-->
20+
<add key="ClearTextPassword" value="%TEL_GITHUB_PACKAGE_READ_PAT%" />
21+
</TELGitNugetFeed>
22+
23+
<TELAzureLearningHubNugetFeed>
24+
<add key="Username" value="%TEL_AZURE_DEVOPS_USERNAME%" />
25+
<!--cleartext for benefit of github actions-->
26+
<add key="ClearTextPassword" value="%TEL_AZURE_DEVOPS_PAT%" />
27+
</TELAzureLearningHubNugetFeed>
28+
</packageSourceCredentials>
29+
30+
<!--Use local package first if not found use remote-->
31+
<!--<packageSource key="TELLocalNugetFeed">
32+
<package pattern="*" />
33+
</packageSource>-->
34+
35+
<packageSourceMapping>
36+
<packageSource key="TELGitNugetFeed">
37+
<package pattern="TELBlazor.*" />
38+
<package pattern="NHSETELViewComponents" />
39+
<!-- Best practice to only apply all to one source but we may want to enable it for convenience (and we do duplicate some packages across both sources) -->
40+
<!-- <package pattern="*" /> -->
41+
</packageSource>
42+
43+
<packageSource key="TELAzureLearningHubNugetFeed">
44+
<package pattern="LearningHub.Nhs.*" />
45+
<package pattern="elfhHub.Nhs.*" />
46+
<package pattern="GDS.MultiPageFormData" />
47+
<package pattern="NHSUKSearchSortFilterPaginate" />
48+
<package pattern="NHSUKViewComponents.Web" />
49+
<package pattern="UK.NHS.CookieBanner" />
50+
<!-- Best practice to only apply all to one source but we may want to enable it for convenience (and we do duplicate some packages across both sources) -->
51+
<!-- <package pattern="*" /> -->
52+
</packageSource>
53+
54+
<!--Check official nuget last-->
55+
<packageSource key="nuget.org">
56+
<package pattern="*" />
57+
</packageSource>
58+
</packageSourceMapping>
59+
</configuration>

0 commit comments

Comments
 (0)