80 lines (70 loc) · 2.39 KB
/
build-and-deploy.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
name: "Build and Deploy .NET Core"
# Controls when the workflow will run
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# This env is sharing between jobs
env:
dotnet_version: '6.0'
artifact_name: web-api
project_path: src/DemoWebAPI
# use {0} for replace expression: https://docs.github.com/en/actions/learn-github-actions/expressions#format
publish_profile_template: AzureAppService_PublishProfile_{0}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.dotnet_version }}
- name: Publish folder
run: |
cd "./${{ env.project_path }}"
dotnet restore
dotnet build --configuration Release
dotnet publish --configuration Release --output ./output
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
with:
name: ${{ env.artifact_name }}
path: '${{ env.project_path }}/output'
retention-days: 1 # Keep artifact on remote only 1 day
deploy:
name: 🚀 Deploy to ${{ matrix.id }}
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
include:
- id: demo_multi_app_cat
name: thadaw-demo-multi-app-cat
resourceGroup: rg-thadaw-demo-multi-app
slot: production
subscription: Azure Subscription
- id: demo_multi_app_dog
name: thadaw-demo-multi-app-dog
resourceGroup: rg-thadaw-demo-multi-app
slot: production
subscription: Azure Subscription
- id: demo_multi_app_ant
name: thadaw-demo-multi-app-ant
resourceGroup: rg-thadaw-demo-multi-app
slot: production
subscription: Azure Subscription
steps:
- name: Deploy
run: echo "${{ matrix.id }}"
- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: ${{ env.artifact_name }}
- name: Deploy to Azure Web App
uses: azure/webapps-deploy@v2
with:
app-name: ${{ matrix.name }}
publish-profile: ${{ secrets[format(env.publish_profile_template, matrix.id)] }}
package: .