-
Notifications
You must be signed in to change notification settings - Fork 4
90 lines (79 loc) · 2.52 KB
/
build.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
name: 'Build and Publish'
on:
push:
branches: [ "master" ]
workflow_dispatch:
env:
DOTNET_VERSION: '6.0.x' # set this to the dotnet version to use
jobs:
build:
name: 'Build'
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v3
- name: 'Setup DotNet ${{ env.DOTNET_VERSION }} Environment'
uses: actions/setup-dotnet@v2
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: 'Run Unit Tests'
run: |
dotnet test --configuration Release --logger "trx;LogFileName=test-results.trx" || true
- name: Test Report
uses: dorny/test-reporter@v1
if: always()
with:
name: DotNET Tests
path: "**/test-results.trx"
reporter: dotnet-trx
fail-on-error: true
- name: 'Publish'
shell: bash
run: |
dotnet build LostFilmMonitoring.AzureFunction/LostFilmMonitoring.AzureFunction.csproj --configuration Release --output publish
- name: 'Store artifact'
uses: actions/upload-artifact@v3
with:
name: azure-functionapp
path: |
publish
if-no-files-found: error
retention-days: 5
deploy_to_staging:
name: 'Deploy to Staging'
runs-on: ubuntu-latest
needs: 'build'
if: ${{ github.ref_name == 'master' || github.ref_name == 'release' }}
environment: 'Staging'
steps:
- name: 'Download artifact'
uses: actions/download-artifact@v3
with:
name: azure-functionapp
path: packageDir
- name: 'Deploy'
uses: Azure/functions-action@v1
with:
app-name: '${{ secrets.AZURE_FUNCTION_APP_NAME }}'
slot-name: 'Production'
package: packageDir
publish-profile: ${{ secrets.AZURE_FUNCTION_PUBLISH_PROFILE }}
deploy_to_Production:
name: 'Deploy to Production'
runs-on: ubuntu-latest
needs: 'deploy_to_staging'
if: ${{ github.ref_name == 'master' || github.ref_name == 'release' }}
environment: 'Production'
steps:
- name: 'Download artifact'
uses: actions/download-artifact@v3
with:
name: azure-functionapp
path: packageDir
- name: 'Deploy'
uses: Azure/functions-action@v1
with:
app-name: '${{ secrets.AZURE_FUNCTION_APP_NAME }}'
slot-name: 'Production'
package: packageDir
publish-profile: ${{ secrets.AZURE_FUNCTION_PUBLISH_PROFILE }}