Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/Build-Test-And-Deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Build, Test, and Deploy EssentialCSharp.Web
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:

permissions:
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/PR-Build-And-Test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: PR Build and Test EssentialCSharp.Web

on:
pull_request:
branches: ["main"]
workflow_dispatch:

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json

- name: Set up dependency caching for faster builds
uses: actions/cache@v4
id: nuget-cache
with:
path: |
~/.nuget/packages
${{ github.workspace }}/**/obj/project.assets.json
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
${{ runner.os }}-nuget-

- name: Restore with dotnet
run: dotnet restore /p:AccessToNugetFeed=false

- name: Build with dotnet
run: dotnet build --configuration Release --no-restore /p:AccessToNugetFeed=false

- name: Run .NET Tests
run: dotnet test --no-build --configuration Release

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Container Image
uses: docker/build-push-action@v6
with:
file: ./EssentialCSharp.Web/Dockerfile
context: .
outputs: type=docker,dest=${{ github.workspace }}/essentialcsharpwebimage.tar
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: ACCESS_TO_NUGET_FEED=false
9 changes: 2 additions & 7 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ jobs:

- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
source-url: https://pkgs.dev.azure.com/intelliTect/_packaging/EssentialCSharp/nuget/v3/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.AZURE_DEVOPS_PAT}}

- name: Set up dependency caching for faster builds
uses: actions/cache@v4
Expand All @@ -55,8 +50,8 @@ jobs:

- name: Restore with dotnet
run: |
dotnet restore
dotnet build --configuration Release --no-restore --no-incremental
dotnet restore /p:AccessToNugetFeed=false
dotnet build --configuration Release --no-restore --no-incremental /p:AccessToNugetFeed=false

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
Expand Down
6 changes: 4 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>false</CentralPackageTransitivePinningEnabled>
<ToolingPackagesVersion>1.1.1.4632</ToolingPackagesVersion>
<AccessToNugetFeed>true</AccessToNugetFeed>
<AccessToNugetFeed>false</AccessToNugetFeed>
<RestoreSources>
https://api.nuget.org/v3/index.json;
</RestoreSources>
Expand All @@ -16,6 +16,8 @@
<PackageVersion Include="ContentFeedNuget" Version="$(ToolingPackagesVersion)" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
<PackageVersion Include="EssentialCSharp.Shared.Models" Version="$(ToolingPackagesVersion)" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.10" />
<PackageVersion Include="AspNet.Security.OAuth.GitHub" Version="8.3.0" />
Expand All @@ -38,4 +40,4 @@
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.1" />
</ItemGroup>
</Project>
</Project>
14 changes: 9 additions & 5 deletions EssentialCSharp.Web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ WORKDIR /app
EXPOSE 8080
EXPOSE 8081

FROM mcr.microsoft.com/dotnet/sdk:9.0.102 AS build
FROM mcr.microsoft.com/dotnet/sdk:8.0.101 AS build
ARG ACCESS_TO_NUGET_FEED=true
ENV ACCESS_TO_NUGET_FEED=$ACCESS_TO_NUGET_FEED
RUN sh -c "$(curl -fsSL https://aka.ms/install-artifacts-credprovider.sh)"
WORKDIR /src
COPY . .
RUN --mount=type=secret,id=nuget_auth_token \
auth_token=$(cat /run/secrets/nuget_auth_token) && \
export VSS_NUGET_EXTERNAL_FEED_ENDPOINTS="{\"endpointCredentials\": [{\"endpoint\":\"https://pkgs.dev.azure.com/intelliTect/_packaging/EssentialCSharp/nuget/v3/index.json\", \"password\":\"$auth_token\"}]}" && \
dotnet restore "EssentialCSharp.Web.sln" && \
dotnet build "EssentialCSharp.Web.sln" -c Release --no-restore && \
if [ "$ACCESS_TO_NUGET_FEED" = "true" ]; then \
auth_token=$(cat /run/secrets/nuget_auth_token) && \
export VSS_NUGET_EXTERNAL_FEED_ENDPOINTS="{\"endpointCredentials\": [{\"endpoint\":\"https://pkgs.dev.azure.com/intelliTect/_packaging/EssentialCSharp/nuget/v3/index.json\", \"password\":\"$auth_token\"}]}"; \
fi && \
dotnet restore "EssentialCSharp.Web.sln" -p:AccessToNugetFeed=$ACCESS_TO_NUGET_FEED && \
dotnet build "EssentialCSharp.Web.sln" -c Release --no-restore -p:AccessToNugetFeed=$ACCESS_TO_NUGET_FEED && \
dotnet publish "EssentialCSharp.Web.sln" -c Release -p:PublishDir=/app/publish -p:UseAppHost=false --no-build

FROM base AS final
Expand Down
15 changes: 10 additions & 5 deletions EssentialCSharp.Web/EssentialCSharp.Web.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PlaceholderHtmlFile Include="$(ProjectDir)Placeholders/*.html" />
<PlaceholderJsonFile Include="$(ProjectDir)Placeholders/*.json" />
<PlaceholderChapterOneHtmlFile Include="$(ProjectDir)/Placeholders/Chapters/01/Pages/*.html" />
<PlaceholderChapterTwoHtmlFile Include="$(ProjectDir)/Placeholders/Chapters/02/Pages/*.html" />
<PlaceholderSitemapJsonFile Include="$(ProjectDir)/Placeholders/sitemap.json" />
<PlaceholderGuidelinesJsonFile Include="$(ProjectDir)/Placeholders/guidelines.json" />
</ItemGroup>

<ItemGroup Condition="$(AccessToNugetFeed)">
Expand All @@ -20,6 +22,7 @@
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand All @@ -40,8 +43,10 @@
</Content>
</ItemGroup>
<Target Condition="!$(AccessToNugetFeed)" Name="CopyPlaceholderContent" BeforeTargets="Build">
<Copy SourceFiles="@(PlaceholderJsonFile)" DestinationFolder="$(ProjectDir)/Chapters/" SkipUnchangedFiles="true" />
<Copy SourceFiles="@(PlaceholderHtmlFile)" DestinationFolder="$(ProjectDir)/Chapters/01/Pages/" SkipUnchangedFiles="true" />
<Copy SourceFiles="@(PlaceholderSitemapJsonFile)" DestinationFolder="$(ProjectDir)/Chapters/" SkipUnchangedFiles="true" />
<Copy SourceFiles="@(PlaceholderGuidelinesJsonFile)" DestinationFolder="$(ProjectDir)/Guidelines/" SkipUnchangedFiles="true" />
<Copy SourceFiles="@(PlaceholderChapterOneHtmlFile)" DestinationFolder="$(ProjectDir)/Chapters/01/Pages/" SkipUnchangedFiles="true" />
<Copy SourceFiles="@(PlaceholderChapterTwoHtmlFile)" DestinationFolder="$(ProjectDir)/Chapters/02/Pages/" SkipUnchangedFiles="true" />
</Target>

<PropertyGroup>
Expand Down
9 changes: 0 additions & 9 deletions EssentialCSharp.Web/Placeholders/01.html

This file was deleted.

Loading
Loading