Skip to content

Compete solution updates (#137) #39

Compete solution updates (#137)

Compete solution updates (#137) #39

# For build guidance only, this workflow does not publish to Dockerhub.
# See workflows/main_build-aspnetcore.yml for an example that builds and publishes an image to Docker Hub
name: Build Blazor Application
on:
workflow_dispatch:
push:
branches:
- main
- "blazor/*"
paths:
- 'src/Blazor/**/*'
- '.github/workflows/main_build-blazor.yml'
jobs:
##############################
####### WINDOWS BUILD ########
##############################
build_windows:
runs-on: windows-2022
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- name: Restore NuGet Packages
run: |
# In this special case, we're using the nested nuget.config file (instead of src/nuget.config)
dotnet restore src\Blazor\MyBlazorApp\MyBlazorApp.csproj --configfile src\Blazor\MyBlazorApp\NuGet.Config --runtime win-x64
dotnet restore src\Blazor\MyBlazorApp.Tests\MyBlazorApp.Tests.csproj --configfile src\Blazor\MyBlazorApp\NuGet.Config --runtime win-x64
env:
TELERIK_USERNAME: ${{ secrets.MyTelerikAccountUsername }}
TELERIK_PASSWORD: ${{ secrets.MyTelerikAccountPassword }}
- name: Build Test Project
run: dotnet build src\Blazor\MyBlazorApp.Tests\MyBlazorApp.Tests.csproj --no-restore --configuration Release --runtime win-x64
- name: Run Tests
run: dotnet test src\Blazor\MyBlazorApp.Tests\MyBlazorApp.Tests.csproj --runtime win-x64
#########################################
####### .NET CONTAINER SDK BUILD ########
#########################################
build_dotnet_container:
runs-on: windows-2022
# For 'akeyless' step
permissions:
id-token: write
contents: read
env:
RID: linux-x64
CONFIGURATION: Release
BLAZOR_PROJ_PATH: src\Blazor\MyBlazorApp\MyBlazorApp.csproj
TEST_PROJ_PATH: src\Blazor\MyBlazorApp.Tests\MyBlazorApp.Tests.csproj
NUGET_CONFIG_PATH: src\Blazor\MyBlazorApp\NuGet.Config
CONTAINER_BASE_IMAGE: "mcr.microsoft.com/dotnet/aspnet:8.0"
CONTAINER_IMAGE_NAME: "lancemccarthy/myblazorapp"
CONTAINER_IMAGE_TAG: "latest"
CONTAINER_IMAGE_REGISTRY: "registry.hub.docker.com"
CONTAINER_RID: "linux-x64"
CONTAINER_ARCH: "x64"
CONTAINER_OS: "linux"
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- name: Restore NuGet Packages
run: |
# In this special case, we're using the nested nuget.config file (instead of src/nuget.config)
dotnet restore ${{ env.BLAZOR_PROJ_PATH }}-configfile ${{ env.NUGET_CONFIG_PATH }} --runtime ${{ env.RID }}
dotnet restore ${{ env.TEST_PROJ_PATH }} --configfile ${{ env.NUGET_CONFIG_PATH }} --runtime ${{ env.RID }}
env:
TELERIK_USERNAME: ${{ secrets.MyTelerikAccountUsername }}
TELERIK_PASSWORD: ${{ secrets.MyTelerikAccountPassword }}
- name: Build Test Project
run: dotnet build ${{ env.TEST_PROJ_PATH }} --no-restore --configuration ${{ env.CONFIGURATION }} --runtime ${{ env.RID }}
- name: Fetch secrets from AKeyless
id: akeyless
uses: LanceMcCarthy/akeyless-action@v3
with:
access-id: ${{ secrets.AKEYLESS_JWT_ID }}
static-secrets: '{"/personal-keys/mccarthy/DOCKER_HUB_USERNAME":"DOCKER_HUB_USERNAME", "/personal-keys/mccarthy/DOCKER_HUB_PAT":"DOCKER_HUB_PAT"}'
export-secrets-to-outputs: true
export-secrets-to-environment: false
- name: Login to Docker Hub
run: docker login ${{ env.CONTAINER_IMAGE_REGISTRY }} -u ${{ steps.akeyless.outputs.DOCKER_HUB_USERNAME }} -p ${{ steps.akeyless.outputs.DOCKER_HUB_PAT }}
# Build and publish the Container build and publish with.NET https://learn.microsoft.com/en-us/dotnet/core/docker/publish-as-container
- name: Publish Blazor Project to Docker Hub
run: dotnet publish ${{ env.BLAZOR_PROJ_PATH }} -c ${{ env.CONFIGURATION }} --no-build --os ${{ env.CONTAINER_OS }} --arch ${{ env.CONTAINER_ARCH }} -p PublishProfile=DefaultContainer -p ContainerRuntimeIdentifier=${{ env.CONTAINER_RID }} -p ContainerRegistry=${{ env.CONTAINER_IMAGE_REGISTRY }} -p ContainerRepository=${{ env.CONTAINER_IMAGE_NAME }} -p ContainerImageTag=${{ env.CONTAINER_IMAGE_TAG }} -p ContainerBaseImage=${{ env.CONTAINER_BASE_IMAGE }}
# env:
# SDK_CONTAINER_REGISTRY_UNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
# SDK_CONTAINER_REGISTRY_PWORD: ${{ secrets.DOCKER_HUB_PAT }}
###################################
####### DOCKER FILE BUILD #########
###################################
build_docker_file:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
# Using GitHub Actions secrets, we can pass in the Telerik NuGet key to be mounted in the Dockerfile's commands
# NOTE: this job does NOT push to Dockerhub because the previous job above already does that
- name: Build Docker
uses: docker/build-push-action@v3
with:
context: src/Blazor/MyBlazorApp
push: false
secrets: |
telerik_username=${{ secrets.MyTelerikAccountUsername }}
telerik_password=${{ secrets.MyTelerikAccountPassword }}
tags: |
lancemccarthy/myblazorapp:latest