-
Notifications
You must be signed in to change notification settings - Fork 3
152 lines (135 loc) · 5.32 KB
/
build-deploy-api.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
142
143
144
145
146
147
148
149
150
151
152
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: Build and release website
on:
push:
branches: [ "master" ]
paths:
- /src/Web/**
- /src/API/**
- /src/Orchestrator/**
- /src/Shared/**
workflow_dispatch:
jobs:
TestApi:
name: Test API
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration "RELEASE"
- name: Test
run: dotnet test --no-build --verbosity normal --configuration "RELEASE"
buildApi:
name: Build API
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore ./src/API/CloudRepublic.BenchMark.API.V2/CloudRepublic.BenchMark.API.V2.csproj
- name: Publish
run: dotnet publish --runtime "win-x64" ./src/API/CloudRepublic.BenchMark.API.V2/CloudRepublic.BenchMark.API.V2.csproj --output ./outputs/api --configuration "RELEASE"
- name: Debugging info
run: ls ./outputs/api
- name: Zip outputs
shell: pwsh
working-directory: ${{ github.workspace }}/outputs/api
run: Compress-Archive .\* ${{ github.workspace }}/api.zip
- name: Upload a Build Artifact
uses: actions/upload-artifact@v3.1.1
with:
name: api
path: ./api.zip
buildTestRunner:
name: Build test runner
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore ./src/Orchestrator/CloudRepublic.BenchMark.Orchestrator.V2/CloudRepublic.BenchMark.Orchestrator.V2.csproj
- name: Publish
run: dotnet publish --runtime "win-x64" ./src/Orchestrator/CloudRepublic.BenchMark.Orchestrator.V2/CloudRepublic.BenchMark.Orchestrator.V2.csproj --output ./outputs/testRunner --configuration "RELEASE"
- name: Debugging info
run: ls ./outputs/testRunner
- name: Zip outputs
shell: pwsh
working-directory: ${{ github.workspace }}/outputs/testRunner
run: Compress-Archive .\* ${{ github.workspace }}/testRunner.zip
- name: Upload a Build Artifact
uses: actions/upload-artifact@v3.1.1
with:
name: testRunner
path: ./testRunner.zip
buildFrontend:
name: Build frontend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 20
- name: install packages
working-directory: ${{ github.workspace }}/src/Web
run: npm install
- name: Build Angular frontend
working-directory: ${{ github.workspace }}/src/Web
run: npm run build
- name: Upload a Build Artifact
uses: actions/upload-artifact@v3.1.1
with:
name: frontend
path: ${{ github.workspace }}/src/Web/dist/serverless-benchmark-dashboard/browser
deploy:
name: Deploy application
runs-on: ubuntu-latest
needs: ["TestApi", "buildApi", "buildTestRunner", "buildFrontend"]
steps:
# Checkout code
- uses: actions/checkout@v3
# Log into Azure
- name: login to azure cli
run: az login --service-principal -u ${{ secrets.AZURE_APPID }} -p ${{ secrets.AZURE_APPSECRET }} --tenant ${{ secrets.AZURE_TENANT }}
- name: deploy bicep
run: az stack group create --subscription "${{ secrets.AZURE_SUBSCRIPTION }}" --resource-group "${{ secrets.AZURE_RG }}" --template-file ./Deployment/deployment.bicep --parameters prefix=${{ secrets.DEPLOYMENT_PREFIX }} --name app --deny-settings-mode None --delete-resources true --deny-settings-excluded-principals ${{ secrets.AZURE_OBJECTID }}
- name: Download API Artifact
uses: actions/download-artifact@v3.0.1
with:
name: api
path: ./outputs/api
- name: Download TestRunner Artifact
uses: actions/download-artifact@v3.0.1
with:
name: testRunner
path: ./outputs/testRunner
- name: Download Frontend Artifact
uses: actions/download-artifact@v3.0.1
with:
name: frontend
path: ./outputs/frontend
- name: Deploy frontend
uses: Azure/static-web-apps-deploy@v1
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_TOKEN }}
action: "upload"
app_location: ./outputs/frontend
skip_app_build: true
skip_api_build: true
- name: Deploy api
run: az functionapp deployment source config-zip --subscription "${{ secrets.AZURE_SUBSCRIPTION }}" --resource-group "${{ secrets.AZURE_RG }}" --src "./outputs/api/api.zip" --name "${{ secrets.DEPLOYMENT_PREFIX }}api"
- name: Deploy test runner
run: az functionapp deployment source config-zip --subscription "${{ secrets.AZURE_SUBSCRIPTION }}" --resource-group "${{ secrets.AZURE_RG }}" --src "./outputs/testRunner/testRunner.zip" --name "${{ secrets.DEPLOYMENT_PREFIX }}testrunner"