-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (85 loc) · 3.18 KB
/
build-test-and-deploy.yml
File metadata and controls
103 lines (85 loc) · 3.18 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
101
102
103
name: Build, Test, and Deploy SyncUp
# https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
# CONFIGURATION
# For help, go to https://github.com/Azure/Actions
#
# 1. Set up the production Environment in the GitHub Repository Settings.
# Environment Protection Rules are recommended to prevent accidental deployments.
# https://docs.github.com/actions/managing-workflow-runs-and-deployments/managing-deployments/managing-environments-for-deployment#deployment-protection-rules
#
# 2. Set up the following secrets in your repository - https://docs.github.com/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-an-environment
# AZURE_WEBAPP_PUBLISH_PROFILE
#
# 3. Change these variables for your configuration:
env:
AZURE_WEBAPP_NAME: SyncUp-dev # set this to your app service name
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Use .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.x
include-preview: true
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x
- name: npm ci
run: npm ci
working-directory: SyncUp.Web
- name: Restore Nuget packages
run: dotnet restore
- name: Check Coalesce has been run
run: dotnet coalesce --what-if --verify
working-directory: SyncUp.Web
- name: npm run lint
run: npm run lint
working-directory: SyncUp.Web
- name: npm run build
run: npm run build
working-directory: SyncUp.Web
- name: dotnet build
run: dotnet build --configuration Release --no-restore --no-incremental
- name: dotnet test
run: dotnet test --configuration Release --no-restore --no-build
- name: dotnet publish
run: dotnet publish ${{ github.workspace }}/SyncUp.Web/SyncUp.Web.csproj --configuration Release --output ${{ github.workspace }}/publish --no-restore --no-build
- name: Upload artifact for deployment
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v4
with:
name: web-app
path: ${{ github.workspace }}/publish
if-no-files-found: error
# Deploys the app to Azure App Service
# https://docs.github.com/actions/use-cases-and-examples/deploying/deploying-net-to-azure-app-service
deploy-development:
needs: build-and-test
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
environment:
name: 'Development'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact for deployment
uses: actions/download-artifact@v4
with:
name: web-app
- name: Deploy to Azure Web App
uses: azure/webapps-deploy@v3
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
slot-name: 'production'
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
package: .