|
9 | 9 | runs-on: windows-latest |
10 | 10 | steps: |
11 | 11 | - uses: actions/checkout@v3 |
12 | | - |
13 | | - - name: Modify web.config |
14 | | - shell: pwsh |
15 | | - run: | |
16 | | - $config = Get-ChildItem -Path "$(Build.SourcesDirectory)" -Recurse -Filter web.config |
17 | | - |
18 | | - if (-not $config.configuration.'system.webServer') { |
19 | | - $systemWebServer = $config.CreateElement("system.webServer") |
20 | | - $config.configuration.AppendChild($systemWebServer) | Out-Null |
21 | | - } else { |
22 | | - $systemWebServer = $config.configuration.'system.webServer' |
23 | | - } |
24 | | - |
25 | | - if (-not $systemWebServer.httpProtocol) { |
26 | | - $httpProtocol = $config.CreateElement("httpProtocol") |
27 | | - $systemWebServer.AppendChild($httpProtocol) | Out-Null |
28 | | - } else { |
29 | | - $httpProtocol = $systemWebServer.httpProtocol |
30 | | - } |
31 | | - |
32 | | - if (-not $httpProtocol.customHeaders) { |
33 | | - $customHeaders = $config.CreateElement("customHeaders") |
34 | | - $httpProtocol.AppendChild($customHeaders) | Out-Null |
35 | | - } else { |
36 | | - $customHeaders = $httpProtocol.customHeaders |
37 | | - } |
38 | | - |
39 | | - foreach ($name in @("X-Powered-By", "Server")) { |
40 | | - $removeNode = $config.CreateElement("remove") |
41 | | - $removeNode.SetAttribute("name", $name) |
42 | | - $customHeaders.AppendChild($removeNode) | Out-Null |
43 | | - } |
44 | | - |
45 | | - if (-not $systemWebServer.security) { |
46 | | - $security = $config.CreateElement("security") |
47 | | - $systemWebServer.AppendChild($security) | Out-Null |
48 | | - } else { |
49 | | - $security = $systemWebServer.security |
50 | | - } |
51 | | - |
52 | | - if (-not $security.requestFiltering) { |
53 | | - $requestFiltering = $config.CreateElement("requestFiltering") |
54 | | - $requestFiltering.SetAttribute("removeServerHeader", "true") |
55 | | - $security.AppendChild($requestFiltering) | Out-Null |
56 | | - } |
57 | | - |
58 | | - $config.Save("${{ github.workspace }}/LearningHub.Nhs.WebUI/web.config") |
59 | | - |
60 | 12 | - name: Setup .NET Core SDK 6.0 |
61 | 13 | uses: actions/setup-dotnet@v3 |
62 | 14 | with: |
|
0 commit comments