-
Notifications
You must be signed in to change notification settings - Fork 21
140 lines (118 loc) · 5.43 KB
/
main_build-blazor.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# 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