-
Notifications
You must be signed in to change notification settings - Fork 4
217 lines (211 loc) · 8.9 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
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
name: Build IOT-DEMO
# Controls when the workflow will run
on:
# Triggers the workflow on pull request event but only for the master branch
pull_request:
types: [opened, synchronize, reopened]
branches: ["master"]
env:
SIMULATOR_AZURE_FUNCTIONS: simulator-azure-functions # set this to your application's name
SIMULATOR_AZURE_FUNCTIONS_PACKAGE_PATH: "./IoTDeviceSimulator/azure-functions/" # set this to the path to your web app project, defaults to the repository root
IoTSERVICE_AZURE_FUNCTIONS: IoTService # set this to your application's name
IoTSERVICE_AZURE_FUNCTIONS_PACKAGE_PATH: "./IoTService/azure-functions/" # set this to the path to your web app project, defaults to the repository root
NODE_VERSION: "16" # set this to the node version you wish to use for the project
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This job detects which project is updated and runs the other build jobs based on the results.
changes_build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Set job outputs to values from filter step
outputs:
web-client: ${{ steps.filter.outputs.web-client }}
IoTVisualizer: ${{ steps.filter.outputs.IoTVisualizer }}
simulator-azure-functions: ${{ steps.filter.outputs.simulator-azure-functions }}
iotService-azure-functions: ${{ steps.filter.outputs.iotService-azure-functions }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# Public repo - https://github.com/dorny/paths-filter
# Github market place - https://github.com/marketplace/actions/paths-changes-filter
# This dorny/paths-filter@v2 action detects changes in repo.
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
web-client:
- 'IoTDeviceSimulator/web-client/**'
IoTVisualizer:
- 'IoTVisualizer/**'
simulator-azure-functions:
- 'IoTDeviceSimulator/azure-functions/**'
iotService-azure-functions:
- 'IoTService/azure-functions/**'
# This job creates optimized build of IoT Simulator web-client project
simulator_webClient_build:
needs: changes_build
if: needs.changes_build.outputs.web-client == 'true'
# The type of runner that the job will run on
runs-on: ubuntu-latest
defaults:
run:
# Setting up default working space to run the commands
working-directory: ./IoTDeviceSimulator/web-client/
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# Setting up the node js
- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
# Cache dependencies for projects
cache-dependency-path: "./IoTDeviceSimulator/web-client/package-lock.json"
# Getting information about events when pipline triggers
- name: Github action event information
run: |
echo github.event_name - ${{github.event_name}}
echo github.event.pull_request.merged - ${{github.event.pull_request.merged }}
echo github.event.action - ${{github.event.action}}
echo Web client running - ${{ needs.changes_build.outputs.web-client}}
# Install dependencies for projects
- name: Install dependencies
run: npm ci
# Creating optimized build
- name: Build
run: npm run build
# Auditing node modules
- name: Audit
run: |
npm audit
continue-on-error: true
# This job build azure functions from IoT Device simulator.
simulator_azureFunctions_build:
needs: changes_build
if: needs.changes_build.outputs.simulator-azure-functions == 'true'
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# Setting up the node js
- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
# Cache dependencies for projects
cache-dependency-path: "./IoTDeviceSimulator/azure-functions/package-lock.json"
# Getting information about events when pipline triggers
- name: Github action event information
run: |
echo github.event_name - ${{github.event_name}}
echo github.event.pull_request.merged - ${{github.event.pull_request.merged }}
echo github.event.action - ${{github.event.action}}
echo azure-functions running - ${{ needs.changes_build.outputs.azure-functions}}
# Install dependencies for projects
# Run build and test related commands if present in package.json
- name: "Resolve Project Dependencies Using Npm"
shell: bash
run: |
pwd
pushd './${{ env.SIMULATOR_AZURE_FUNCTIONS_PACKAGE_PATH }}'
pwd
npm ci
npm run build --if-present
npm run test --if-present
pwd
popd
pwd
# Auditing node modules
- name: Audit
run: |
npm audit
continue-on-error: true
# This job build azure functions from IoTService.
iotService_azureFunctions_build:
needs: changes_build
if: needs.changes_build.outputs.iotService-azure-functions == 'true'
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# Setting up the node js
- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
# Cache dependencies for projects
cache-dependency-path: "./IoTService/azure-functions/package-lock.json"
# Getting information about events when pipline triggers
- name: Github action event information
run: |
echo github.event_name - ${{github.event_name}}
echo github.event.pull_request.merged - ${{github.event.pull_request.merged }}
echo github.event.action - ${{github.event.action}}
echo IoTService running - ${{ needs.changes_build.outputs.IoTService}}
# Install dependencies for projects
# Run build and test related commands if present in package.json
- name: "Resolve Project Dependencies Using Npm"
shell: bash
run: |
pwd
pushd './${{ env.IoTSERVICE_AZURE_FUNCTIONS_PACKAGE_PATH }}'
pwd
npm ci
npm run build --if-present
npm run test --if-present
pwd
popd
pwd
# Auditing node modules
- name: Audit
run: |
npm audit
continue-on-error: true
# This job creates optimized build of IoT Visualizer project
iotVisualizer_build:
needs: changes_build
if: needs.changes_build.outputs.IoTVisualizer == 'true'
# The type of runner that the job will run on
runs-on: ubuntu-latest
defaults:
run:
# Setting up default working space to run the commands
working-directory: ./IoTVisualizer/
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# Setting up the node js
- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
# Cache dependencies for projects
cache-dependency-path: "./IoTVisualizer/package-lock.json"
# Getting information about events when pipline triggers
- name: Github action event information
run: |
echo github.event_name - ${{github.event_name}}
echo github.event.pull_request.merged - ${{github.event.pull_request.merged }}
echo github.event.action - ${{github.event.action}}
echo IoT Visualizer running - ${{ needs.changes_build.outputs.IoTVisualizer}}
# Install dependencies for projects
- name: Install dependencies
run: npm ci
# Creating optimized build
- name: Build
run: npm run build
# Auditing node modules
- name: Audit
run: |
npm audit
continue-on-error: true