-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (116 loc) · 4.42 KB
/
devops-starter-workflow.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
141
name: Deploy ASP.NET Core app to Azure Web App
on:
push:
branches:
- master
env:
AZURE_WEBAPP_NAME: "az400m08l01-adiaz" # set this to your application's name
AZURE_WEBAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
DOTNET_VERSION: '3.1.302' # set this to the dot net version to use
RESOURCEGROUPNAME: "az400m08l01-adiaz-rg"
LOCATION: "East US"
HOSTINGPLANNAME: "az400m08l01-adiaz-plan"
APPINSIGHTLOCATION: "East US"
SKU: "S1 Standard"
jobs:
build:
runs-on: ubuntu-latest
steps:
# Checkout the repo
- uses: actions/checkout@master
- name: Creating artifact directories
run: |
mkdir buildartifacts
mkdir deploymenttemplates
# Setup .NET Core SDK
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
# Run dotnet build and publish
- name: dotnet build unit test and publish
run: |
cd Application
dotnet restore
dotnet build --configuration Release
dotnet test aspnet-core-dotnet-core.UnitTests/aspnet-core-dotnet-core.UnitTests.csproj
dotnet publish -c Release -o '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/build'
- name: Archive Application
run: |
zip -qq -r ./buildartifacts/Application.zip ./Application/build
- name: Upload Application to Build Artifact
continue-on-error: false
uses: actions/upload-artifact@v2
with:
name: buildartifacts
path: buildartifacts
- name: Archive ArmTemplates
run: |
zip -qq -r ./deploymenttemplates/ArmTemplates.zip ./ArmTemplates
- name: Upload Arm templates to Artifact
continue-on-error: false
uses: actions/upload-artifact@v2
with:
name: deploymenttemplates
path: deploymenttemplates
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download Build Artifact
uses: actions/download-artifact@v2
continue-on-error: false
with:
name: buildartifacts
path: buildartifacts
- name: Unzipping Build artifact
run: |
unzip -qq ./buildartifacts/Application.zip -d .
- name: Download an ARM template
uses: actions/download-artifact@v2
continue-on-error: false
with:
name: deploymenttemplates
path: deploymenttemplates
- name: Unzipping ARM artifact
run: |
unzip -qq ./deploymenttemplates/ArmTemplates.zip -d .
- name: Login to Azure
uses: azure/login@v1
continue-on-error: false
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Deploy ARM Template
uses: azure/CLI@v1
continue-on-error: false
with:
inlineScript: |
az group create --name "${{ env.RESOURCEGROUPNAME }}" --location "${{ env.LOCATION }}"
az deployment group create --resource-group "${{ env.RESOURCEGROUPNAME }}" --template-file ./ArmTemplates/windows-webapp-template.json --parameters webAppName="${{ env.AZURE_WEBAPP_NAME }}" hostingPlanName="${{ env.HOSTINGPLANNAME }}" appInsightsLocation="${{ env.APPINSIGHTLOCATION }}" sku="${{ env.SKU }}"
- name: 'Deploy web app'
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
package: '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/Application/build'
FunctionalTests:
name: Functional tests
runs-on: windows-latest
needs: deploy
steps:
- uses: actions/checkout@master
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: update web app url in Run Settings
shell: powershell
run: |
cd Application\aspnet-core-dotnet-core.FunctionalTests
[xml]$runSetting = Get-Content functionalTests.runsettings
$runSetting.RunSettings.TestRunParameters.ChildNodes.Item(0).value = 'https://${{ env.AZURE_WEBAPP_NAME }}.azurewebsites.net/'
$runSetting.Save("$(pwd)/functionalTests.runsettings")
- name: Run tests
continue-on-error: false
run: |
cd Application\aspnet-core-dotnet-core.FunctionalTests
dotnet test aspnet-core-dotnet-core.FunctionalTests.csproj -s functionalTests.runsettings