forked from jasontaylordev/CleanArchitecture
-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (82 loc) · 2.47 KB
/
dotnet-deploy.yml
File metadata and controls
100 lines (82 loc) · 2.47 KB
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
name: Build & Deploy
on:
push:
branches: [ main ]
env:
as-name: "as-cast"
rg-name: "rg-cast"
jobs:
build:
runs-on: ubuntu-latest
services:
sql:
image: mcr.microsoft.com/mssql/server
ports:
- 1433:1433
env:
SA_PASSWORD: Your_password123
ACCEPT_EULA: Y
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Test
run: dotnet test --no-build --configuration Release --filter "FullyQualifiedName!~AcceptanceTests"
env:
ConnectionStrings__DefaultConnection: Server=.;Database=CleanArchitectureDb-Test;User=sa;Password=Your_password123;MultipleActiveResultSets=true;
- name: Publish
run: dotnet publish src/WebUI/WebUI.csproj --configuration Release --output website
- name: Upload a Build Artifact
uses: actions/upload-artifact@v2.2.2
with:
name: website
path: /home/runner/work/CleanArchitecture/CleanArchitecture/website/**
if-no-files-found: error
deploy-staging:
needs: build
runs-on: ubuntu-latest
environment:
name: staging
url: ${{ steps.deploywebapp.outputs.webapp-url }}
steps:
- name: Download a Build Artifact
uses: actions/download-artifact@v2.0.8
with:
name: website
path: website
- name: Login via Azure CLI
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Deploy web app
id: deploywebapp
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.as-name }}
slot-name: staging
package: website
- name: Logout via Azure CLI
run: az logout
deploy-prod:
needs: deploy-staging
runs-on: ubuntu-latest
environment:
name: prod
url: ${{ steps.slot_swap.outputs.url }}
steps:
- name: Login via Azure CLI
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Swap Staging and Prod
id: slot_swap
run: |
az webapp deployment slot swap -g ${{ env.rg-name }} -n ${{ env.as-name }} -s staging
url=$(az webapp show -g ${{ env.rg-name }} -n ${{ env.as-name }} --query "defaultHostName" -o tsv)
echo "::set-output name=url::https://$url"
- name: Logout via Azure CLI
run: az logout