From 4c1235267cc2c3a4b15f6c9a3009be2bc7a4919c Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Wed, 11 Jun 2025 14:28:00 +0100 Subject: [PATCH] try and trigger the workflow_dispatch event --- .github/workflows/dotnet.yml | 31 +++++++++++++++++++++++ .vscode/launch.json | 13 +++++----- Dockerfile | 21 --------------- Makefile | 9 +++++++ src/Yavsc/Extensions/HostingExtensions.cs | 15 ++++++++--- 5 files changed, 58 insertions(+), 31 deletions(-) delete mode 100644 Dockerfile diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 217f7cbe..ec5ea35f 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -4,12 +4,43 @@ name: .NET on: + workflow_dispatch: + inputs: + logLevel: + description: 'Log level' + required: true + default: 'warning' + type: choice + options: + - info + - warning + - debug + tags: + description: 'Test scenario tags' + required: false + type: boolean + environment: + description: 'Environment to run tests against' + type: environment + required: true push: branches: [ "main" ] pull_request: branches: [ "main" ] jobs: + log-the-inputs: + runs-on: ubuntu-latest + steps: + - run: | + echo "Log level: $LEVEL" + echo "Tags: $TAGS" + echo "Environment: $ENVIRONMENT" + env: + LEVEL: ${{ inputs.logLevel }} + TAGS: ${{ inputs.tags }} + ENVIRONMENT: ${{ inputs.environment }} + build: runs-on: ubuntu-latest diff --git a/.vscode/launch.json b/.vscode/launch.json index 5b376e32..ed62f985 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,7 +5,8 @@ "version": "0.2.0", "configurations": [ - /* { + + /* { "name": ".NET Core Launch (web-client)", "type": "coreclr", "request": "launch", @@ -24,7 +25,7 @@ "sourceFileMap": { "/Views": "${workspaceFolder}/Views" } - }, + }, { "name": ".NET Core Launch (Api)", "type": "coreclr", @@ -36,11 +37,12 @@ "stopAtEntry": false, "console": "internalConsole" }, - { + */ + { "name": ".NET Core Launch (web)", "type": "coreclr", "request": "launch", - "preLaunchTask": "build-web", + "preLaunchTask": "build", "program": "${workspaceFolder}/src/Yavsc/bin/Debug/net8.0/Yavsc.dll", "args": [], "cwd": "${workspaceFolder}/src/Yavsc", @@ -55,8 +57,7 @@ "sourceFileMap": { "/Views": "${workspaceFolder}/Views" } - },*/ - + }, { "name": "webApi", "type": "dotnet", diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 27d1b9b5..00000000 --- a/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ - -FROM mcr.microsoft.com/dotnet/sdk:8.0@sha256:35792ea4ad1db051981f62b313f1be3b46b1f45cadbaa3c288cd0d3056eefb83 AS build -WORKDIR /workdir - -# Copy everything -COPY . ./ -# Restore as distinct layers -RUN dotnet restore -# Build and publish a release -RUN dotnet publish -c Release -o out src/Yavsc/Yavsc.csproj - -# Build runtime image -FROM mcr.microsoft.com/dotnet/aspnet:8.0@sha256:6c4df091e4e531bb93bdbfe7e7f0998e7ced344f54426b7e874116a3dc3233ff -WORKDIR /workdir -COPY --from=build /workdir/out . -ENV ASPNETCORE_ENVIRONMENT=lua -EXPOSE 85/TCP -EXPOSE 86/TCP - -ENTRYPOINT ["dotnet", "Yavsc.dll"] - diff --git a/Makefile b/Makefile index 55220f10..1d1229d2 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ CONFIG=Debug FRAMEWORK=net8.0 +DESTDIR=/tmp/yavsc clean: dotnet clean @@ -23,4 +24,12 @@ src/Yavsc.Server/bin/$(CONFIG)/$(FRAMEWORK)/Yavsc.Server.dll: src/Yavsc/bin/$(CONFIG)/$(FRAMEWORK)/Yavsc.dll: dotnet build -p:Configuration=$(CONFIG) --project src/Yavsc/Yavsc.csproj + +publish: + dotnet publish src/Yavsc/Yavsc.csproj -c Release -o $(DESTDIR)/srv/www/yavsc + +install: publish + chown -R www-data $(DESTDIR)/srv/www/yavsc + chgrp -R www-data $(DESTDIR)/srv/www/yavsc + .PHONY: diff --git a/src/Yavsc/Extensions/HostingExtensions.cs b/src/Yavsc/Extensions/HostingExtensions.cs index f5e0fe52..0e506813 100644 --- a/src/Yavsc/Extensions/HostingExtensions.cs +++ b/src/Yavsc/Extensions/HostingExtensions.cs @@ -30,6 +30,8 @@ using Yavsc.Services; using Yavsc.Settings; using Yavsc.ViewModels.Auth; using Yavsc.Server.Helpers; +using System.Security.Cryptography; +using Microsoft.IdentityModel.Tokens; namespace Yavsc.Extensions; @@ -300,13 +302,18 @@ public static class HostingExtensions } else { - var path = builder.Configuration["Kestrel:Endpoints:Https:KeyPath"]; - var pass = builder.Configuration["Kestrel:Endpoints:Https:Password"]; + var path = builder.Configuration["SigningCert:Path"]; + var pass = builder.Configuration["SigningCert:Password"]; Debug.Assert(path != null); FileInfo certFileInfo = new FileInfo(path); Debug.Assert(certFileInfo.Exists); - var cert = new X509Certificate2(path, pass); - identityServerBuilder.AddSigningCredential(cert); + RSA rsa = RSA.Create(); + rsa.ImportFromPem(File.ReadAllText(certFileInfo.FullName)); + var signingCredentials = new SigningCredentials(new RsaSecurityKey(rsa), SecurityAlgorithms.RsaSha256) + { + CryptoProviderFactory = new CryptoProviderFactory { CacheSignatureProviders = false } + }; + identityServerBuilder.AddSigningCredential(signingCredentials); } return identityServerBuilder; }