-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathazure-pipelines.yml
121 lines (106 loc) · 2.91 KB
/
azure-pipelines.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
# Run pipeline on main branch, pull-requests into main, and tags
trigger:
branches:
include:
- main
- refs/tags/*
pr:
- main
pool:
vmImage: ubuntu-latest
stages:
- stage: Test
jobs:
- job: Test
steps:
- task: Gitleaks@2
displayName: 'Scan for secrets'
inputs:
scanlocation: '.'
configtype: 'custom'
scanmode: 'nogit'
uploadresults: false
reportformat: 'json'
verbose: true
- task: NodeTool@0
displayName: 'Install Node.js'
inputs:
versionSpec: '20.x'
- script: npm ci
displayName: 'Npm Install'
- task: SonarCloudPrepare@1
displayName: 'Prepare analysis on SonarCloud'
inputs:
SonarCloud: 'SonarCloud'
organization: 'nhsdigital'
scannerMode: 'CLI'
projectKey: 'nhsuk-user-feedback-store'
projectName: 'User Feedback Store'
extraProperties: |
sonar.projectKey=nhsuk-user-feedback-store
sonar.exclusions=$(System.DefaultWorkingDirectory)/dependency-scan-results/**
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.coverage.exclusions=**/*.config.js,**/coverage/**
sonar.exclusions=node_modules/**
sonar.language=js
- script: npm run test
displayName: 'Npm Test'
- task: SonarCloudAnalyze@1
displayName: 'Run SonarCloud Code Analysis'
- task: SonarCloudPublish@1
displayName: 'Publish Quality Gate Result'
inputs:
pollingTimeoutSec: '300'
- task: sonarcloud-buildbreaker@2
displayName: "Break the build if the quality gate fails"
inputs:
SonarCloud: 'SonarCloud'
organization: 'nhsdigital'
- stage: DevDeployment
displayName: 'Dev Deployment'
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/heads/main'))
dependsOn:
- Test
jobs:
- deployment: Deployment
environment: 'dev'
strategy:
runOnce:
deploy:
steps:
- template: azure-pipeline-templates/deploy.yaml
parameters:
environment: 'dev'
region: 'uks'
- stage: StagDeployment
displayName: 'Stag Deployment'
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
dependsOn:
- Test
jobs:
- deployment: Deployment
environment: 'staging'
strategy:
runOnce:
deploy:
steps:
- template: azure-pipeline-templates/deploy.yaml
parameters:
environment: 'stag'
region: 'uks'
- stage: ProdDeployment
displayName: 'Prod Deployment'
dependsOn:
- StagDeployment
- Test
jobs:
- deployment: Deployment
environment: 'production'
strategy:
runOnce:
deploy:
steps:
- template: azure-pipeline-templates/deploy.yaml
parameters:
environment: 'prod'
region: 'uks'