1
+ name : .NET CI
2
+
3
+ env :
4
+ registryName : pgtechexcelteam03.azurecr.io
5
+ repositoryName : techexcel/dotnetcoreapp
6
+ dockerFolderPath : ./src/Application/src/RazorPagesTestSample
7
+ my_prefix : pgtechexcelteam03
8
+ my_registry_name : pgtechexcelteam03
9
+ tag : ${{github.run_number}}
10
+
11
+ on :
12
+ push :
13
+ branches : [ main, ci-cd ]
14
+ paths : src/Application/**
15
+ pull_request :
16
+ branches : [ main, ci-cd ]
17
+ paths : src/Application/**
18
+ # Allows you to run this workflow manually from the Actions tab
19
+ workflow_dispatch :
20
+ jobs :
21
+ build :
22
+
23
+ runs-on : ubuntu-latest
24
+
25
+ steps :
26
+ - uses : actions/checkout@v3
27
+ - name : Setup .NET
28
+ uses : actions/setup-dotnet@v3
29
+ with :
30
+ dotnet-version : 8.0
31
+
32
+ - name : Restore dependencies
33
+ run : dotnet restore ./src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj
34
+ - name : Build
35
+ run : dotnet build --no-restore ./src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj
36
+ - name : Test
37
+ run : dotnet test --no-build --verbosity normal ./src/Application/tests/RazorPagesTestSample.Tests/RazorPagesTestSample.Tests.csproj
38
+
39
+ dockerBuildPush :
40
+ runs-on : ubuntu-latest
41
+ needs : build
42
+
43
+ steps :
44
+ - uses : actions/checkout@v3
45
+
46
+ - name : Docker Login
47
+ # You may pin to the exact commit or the version.
48
+ # uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
49
+
50
+ with :
51
+ # Server address of Docker registry. If not set then will default to Docker Hub
52
+ registry : ${{ secrets.ACR_LOGIN_SERVER }}
53
+ # Username used to log against the Docker registry
54
+ username : ${{ secrets.ACR_USERNAME }}
55
+ # Password or personal access token used to log against the Docker registry
56
+ password : ${{ secrets.ACR_PASSWORD }}
57
+ # Log out from the Docker registry at the end of a job
58
+ logout : true
59
+
60
+ - name : Docker Build
61
+ run : docker build -t $registryName/$repositoryName:$tag --build-arg build_version=$tag $dockerFolderPath
62
+
63
+ - name : Docker Push
64
+ run : docker push $registryName/$repositoryName:$tag
65
+
66
+ deploy-to-dev :
67
+
68
+ runs-on : ubuntu-latest
69
+ needs : dockerBuildPush
70
+ environment :
71
+ name : dev
72
+ url : https://${my_prefix}-dev.azurewebsites.net/
73
+
74
+ steps :
75
+ - name : ' Login via Azure CLI'
76
+
77
+ with :
78
+ creds : ${{ secrets.AZURE_CREDENTIALS }}
79
+
80
+ - uses : azure/webapps-deploy@v2
81
+ with :
82
+ app-name : ' {my_prefix}-dev'
83
+ images : ${my_registry_name}.azurecr.io/techexcel/dotnetcoreapp:${{github.run_number}}
84
+
85
+ deploy-to-test :
86
+
87
+ runs-on : ubuntu-latest
88
+ needs : deploy-to-dev
89
+ environment :
90
+ name : test
91
+ url : https://${my_prefix}-test.azurewebsites.net/
92
+
93
+ steps :
94
+ - uses : actions/checkout@v3
95
+
96
+ - name : ' Login via Azure CLI'
97
+
98
+ with :
99
+ creds : ${{ secrets.AZURE_CREDENTIALS }}
100
+
101
+ - uses : azure/webapps-deploy@v2
102
+ with :
103
+ app-name : ' ${my_prefix}-test'
104
+ images : ${my_registry_name}.azurecr.io/techexcel/dotnetcoreapp:${{github.run_number}}
105
+
106
+ deploy-to-prod :
107
+
108
+ runs-on : ubuntu-latest
109
+ needs : deploy-to-test
110
+ environment :
111
+ name : prod
112
+ url : https://${my_prefix}-prod.azurewebsites.net/
113
+
114
+ steps :
115
+ - uses : actions/checkout@v3
116
+
117
+ - name : ' Login via Azure CLI'
118
+
119
+ with :
120
+ creds : ${{ secrets.AZURE_CREDENTIALS }}
121
+
122
+ - uses : azure/webapps-deploy@v2
123
+ with :
124
+ app-name : ' {your_prefix}-prod'
125
+ images : ${my_registry_name}.azurecr.io/techexcel/dotnetcoreapp:${{github.run_number}}
0 commit comments