-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (86 loc) · 2.8 KB
/
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
name: Api
on:
push:
paths:
- "api/**"
- "tests/**"
- ".github/workflows/api.yml"
- ".github/workflows/e2e-tests.yml"
workflow_dispatch:
inputs:
deploy:
description: "Force deployment"
required: false
default: "false"
jobs:
build:
name: Build API
runs-on: ubuntu-20.04
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.x.x"
- name: Start MongoDB (for tests)
run: sudo systemctl start mongod
- name: Run tests
run: dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
working-directory: api
- name: Get current time
uses: josStorer/get-current-time@v2
id: current-time
- name: Publish
run: dotnet publish ./Engraved.Api/Engraved.Api.csproj -c Release -o "${{env.DOTNET_ROOT}}/Engraved.Api" -p:SourceRevisionId=${{github.run_number}}+${{github.sha}}+${{steps.current-time.outputs.time}}
working-directory: api
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: api
path: ${{env.DOTNET_ROOT}}/Engraved.Api
e2e-tests:
name: "E2E Tests"
uses: ./.github/workflows/e2e-tests.yml
deploy-windows:
name: Deploy API (Windows)
runs-on: ubuntu-latest
needs: [build, e2e-tests]
if: github.ref == 'refs/heads/main' || github.event.inputs.deploy == 'true'
environment:
name: "Production"
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: api
- name: Deploy to Azure App Service (Windows)
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: "engraved"
slot-name: "Production"
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_CF17B8AFBCD14051B9CD5C069F5E294E }}
package: .
deploy-linux:
name: Deploy API (Linux)
runs-on: ubuntu-latest
needs: [build, e2e-tests]
if: github.ref == 'refs/heads/main' || github.event.inputs.deploy == 'true'
environment:
name: "Production"
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: api
- name: Deploy to Azure App Service (Linux)
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: "engraved-lnx"
slot-name: "Production"
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_CF17B8AFBCD14051B9CD5C069F5E294E_LNX }}
package: .