Skip to content

Commit 4be1e38

Browse files
committed
Refactor dotnet.yml to include specific paths for push and pull_request events and update Dockerfile for .NET 8
1 parent dfee373 commit 4be1e38

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

.github/workflows/dotnet.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ on:
1515
workflow_dispatch:
1616

1717

18+
env:
19+
registryName: "q3zpru2gmy754mpnpreg.azurecr.io" # Replace registryName with the name of your registry
20+
repositoryName: "techexcel/dotnetcoreapp"
21+
dockerFolderPath: "src/Application/src/RazorPagesTestSample"
22+
tag: ${{ github.run_number }}
23+
1824
jobs:
1925
build:
2026

@@ -31,4 +37,18 @@ jobs:
3137
- name: Build
3238
run: dotnet build src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj --no-restore
3339
- name: Test
34-
run: dotnet test src/Application/tests/RazorPagesTestSample.Tests/RazorPagesTestSample.Tests.csproj --no-build --verbosity normal
40+
run: dotnet test src/Application/tests/RazorPagesTestSample.Tests/RazorPagesTestSample.Tests.csproj --no-build --verbosity normal
41+
42+
buildacr:
43+
runs-on: ubuntu-latest
44+
45+
steps:
46+
- uses: actions/checkout@v4
47+
48+
- name: Login to Azure Container Registry
49+
run: echo "${{ secrets.ACR_PASSWORD }}" | docker login ${{ env.registryName }} -u ${{ secrets.ACR_USERNAME }} --password-stdin
50+
51+
- name: Build and push Docker image
52+
run: |
53+
docker build ${{ env.dockerFolderPath }} -t ${{ env.registryName }}/${{ env.repositoryName }}:${{ env.tag }}
54+
docker push ${{ env.registryName }}/${{ env.repositoryName }}:${{ env.tag }}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Update the base and SDK images to .NET 8
2+
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
3+
WORKDIR /app
4+
EXPOSE 8080
5+
EXPOSE 8081
6+
7+
8+
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
9+
WORKDIR /src
10+
COPY ["RazorPagesTestSample.csproj", "./"]
11+
RUN dotnet restore "./RazorPagesTestSample.csproj"
12+
COPY . .
13+
WORKDIR "/src/."
14+
RUN dotnet build "RazorPagesTestSample.csproj" -c Release -o /app/build
15+
16+
FROM build AS publish
17+
RUN dotnet publish "RazorPagesTestSample.csproj" -c Release -o /app/publish
18+
19+
FROM base AS final
20+
WORKDIR /app
21+
COPY --from=publish /app/publish .
22+
ENTRYPOINT ["dotnet", "RazorPagesTestSample.dll"]

0 commit comments

Comments
 (0)