Skip to content

Commit 7999f45

Browse files
committed
Refactor .NET CI workflow to support CI/CD; streamline paths and update .NET version handling
1 parent a73e042 commit 7999f45

File tree

1 file changed

+14
-67
lines changed

1 file changed

+14
-67
lines changed

.github/workflows/dotnet-deploy-1.yml

Lines changed: 14 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,42 @@
1-
name: .NET CI
1+
name: .NET CI/CD
22

3-
env:
4-
registryName: mpplabajep.azurecr.io
5-
repositoryName: techexcel/dotnetcoreapp
6-
dockerFolderPath: ./src/Application/src/RazorPagesTestSample
7-
tag: ${{github.run_number}}
8-
93
on:
104
push:
115
branches: [ main ]
12-
paths: src/Application/**
6+
paths:
7+
- src/Application/**
138
pull_request:
149
branches: [ main ]
15-
paths: src/Application/**
10+
paths:
11+
- src/Application/**
1612
# Allows you to run this workflow manually from the Actions tab
1713
workflow_dispatch:
14+
1815
jobs:
1916
build:
20-
2117
runs-on: ubuntu-latest
2218

2319
steps:
2420
- uses: actions/checkout@v3
2521
- name: Setup .NET
2622
uses: actions/setup-dotnet@v3
2723
with:
28-
dotnet-version: 8.0
29-
24+
dotnet-version: '8.0.x'
25+
3026
- name: Restore dependencies
31-
run: dotnet restore ./src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj
27+
run: dotnet restore src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj
3228
- name: Build
33-
run: dotnet build --no-restore ./src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj
29+
run: dotnet build --no-restore src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj
3430
- name: Test
35-
run: dotnet test --no-build --verbosity normal ./src/Application/tests/RazorPagesTestSample.Tests/RazorPagesTestSample.Tests.csproj
36-
37-
dockerBuildPush:
38-
39-
runs-on: ubuntu-latest
40-
needs: build
41-
42-
steps:
43-
- uses: actions/checkout@v3
44-
45-
- name: Docker Login
46-
# You may pin to the exact commit or the version.
47-
# uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
48-
uses: docker/[email protected]
49-
with:
50-
# Server address of Docker registry. If not set then will default to Docker Hub
51-
registry: ${{ secrets.ACR_LOGIN_SERVER }}
52-
# Username used to log against the Docker registry
53-
username: ${{ secrets.ACR_USERNAME }}
54-
# Password or personal access token used to log against the Docker registry
55-
password: ${{ secrets.ACR_PASSWORD }}
56-
# Log out from the Docker registry at the end of a job
57-
logout: true
58-
59-
- name: Docker Build
60-
run: docker build -t $registryName/$repositoryName:$tag --build-arg build_version=$tag $dockerFolderPath
61-
62-
- name: Docker Push
63-
run: docker push $registryName/$repositoryName:$tag
64-
65-
deploy-to-dev:
66-
67-
runs-on: ubuntu-latest
68-
needs: dockerBuildPush
69-
environment:
70-
name: dev
71-
url: https://mpplabajep-dev.azurewebsites.net/
72-
73-
steps:
74-
- name: 'Login via Azure CLI'
75-
uses: azure/[email protected]
76-
with:
77-
creds: ${{ secrets.AZURE_CREDENTIALS }}
78-
79-
- uses: azure/webapps-deploy@v2
80-
with:
81-
app-name: 'mpplabajep-dev'
82-
images: mpplabajep.azurecr.io/techexcel/dotnetcoreapp:${{github.run_number}}
31+
run: dotnet test --no-build --verbosity normal src/Application/tests/RazorPagesTestSample.Tests/RazorPagesTestSample.Tests.csproj
8332

8433
deploy-to-test:
85-
8634
runs-on: ubuntu-latest
87-
needs: deploy-to-dev
35+
needs: build
8836
environment:
8937
name: test
9038
url: https://mpplabajep-test.azurewebsites.net/
91-
39+
9240
steps:
9341
- uses: actions/checkout@v3
9442

@@ -103,13 +51,12 @@ jobs:
10351
images: mpplabajep.azurecr.io/techexcel/dotnetcoreapp:${{github.run_number}}
10452

10553
deploy-to-prod:
106-
10754
runs-on: ubuntu-latest
10855
needs: deploy-to-test
10956
environment:
11057
name: prod
11158
url: https://mpplabajep-prod.azurewebsites.net/
112-
59+
11360
steps:
11461
- uses: actions/checkout@v3
11562

0 commit comments

Comments
 (0)