7
7
# -- TESTS ------------------------------------------------------------------
8
8
tests :
9
9
runs-on : ubuntu-latest
10
-
10
+
11
11
strategy :
12
12
matrix :
13
- node-version : [12.x]
13
+ node : ['16']
14
+ mongodb : ['5.0']
14
15
15
16
steps :
16
17
- name : Checkout
17
- uses : actions/checkout@v2
18
+ uses : actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # tag=v3.0.0
18
19
19
- - name : Use Node.js ${{ matrix.node-version }}
20
- uses : actions/setup-node@v1
20
+ - name : Setup Node.js ${{ matrix.node }}
21
+ uses : actions/setup-node@56337c425554a6be30cdef71bf441f15be286854 # tag=v3
21
22
with :
22
- node-version : ${{ matrix.node-version }}
23
+ node-version : ${{ matrix.node }}
24
+ check-latest : true
23
25
24
26
- name : Install dependencies
25
27
run : npm install
26
28
29
+ - name : Start MongoDB
30
+ uses : supercharge/mongodb-github-action@e815fd8a9dfede09fd6e6c144f2c9f4875e933df # tag=1.7.0
31
+ with :
32
+ mongodb-version : ${{ matrix.mongodb }}
33
+ mongodb-db : encryptionAPI
34
+
27
35
- name : Run Unit-Tests + Code Coverage
28
36
run : npm run test:coverage
29
37
30
38
- name : Save Code Coverage
31
- uses : actions/upload-artifact@v2
39
+ uses : actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # tag=v3.0.0
32
40
with :
33
41
name : code-coverage
34
42
path : coverage
35
43
36
- sonarcloud :
44
+ # -- SONARCLOUD -------------------------------------------------------------
45
+ code-quality :
37
46
runs-on : ubuntu-latest
38
47
needs : tests
39
48
40
49
steps :
41
50
- name : Checkout
42
- uses : actions/checkout@v2
43
-
51
+ uses : actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # tag=v3.0.0
52
+
44
53
- name : Download Code Coverage
45
- uses : actions/download-artifact@v2
54
+ uses : actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # tag=v3.0.0
46
55
with :
47
56
name : code-coverage
48
57
path : coverage
66
75
67
76
# - name: Build docker image
68
77
# run: docker build -t timoa/nodejs-encryption-api-example .
69
-
78
+
70
79
# - name: Start Docker container
71
80
# run: docker-compose up -d
72
81
@@ -78,25 +87,92 @@ jobs:
78
87
79
88
# - name: Run Functional tests
80
89
# run: npm run test:functional
81
-
90
+
82
91
# - name: Stop Docker container
83
92
# run: docker-compose down
84
93
94
+ # -- SAST SCAN --------------------------------------------------------------
95
+ code-security :
96
+ runs-on : ubuntu-latest
97
+ needs : tests
98
+ # Skip any PR created by dependabot to avoid permission issues
99
+ if : (github.actor != 'dependabot[bot]')
100
+
101
+ steps :
102
+ - name : Checkout
103
+ uses : actions/checkout@dcd71f646680f2efd8db4afa5ad64fdcba30e748 # tag=v3
104
+
105
+ - name : Perform Scan
106
+ uses : ShiftLeftSecurity/scan-action@master
107
+
108
+ env :
109
+ WORKSPACE : https://github.com/${{ github.repository }}/blob/${{ github.sha }}
110
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
111
+ SCAN_ANNOTATE_PR : true
112
+
113
+ - uses : actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # tag=v3.0.0
114
+ with :
115
+ name : reports
116
+ path : reports
117
+
118
+ # -- RELEASE ----------------------------------------------------------------
119
+ release :
120
+ runs-on : ubuntu-latest
121
+ needs :
122
+ - code-quality
123
+ - code-security
124
+ if : github.ref == 'refs/heads/master'
125
+
126
+ steps :
127
+ - name : Checkout
128
+ uses : actions/checkout@dcd71f646680f2efd8db4afa5ad64fdcba30e748 # tag=v3
129
+
130
+ - name : Semantic Release
131
+ uses : cycjimmy/semantic-release-action@v3
132
+ env :
133
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
134
+
85
135
# -- BUILD ------------------------------------------------------------------
86
136
build :
87
137
runs-on : ubuntu-latest
88
- needs : tests
138
+ needs : release
89
139
if : github.ref == 'refs/heads/master'
90
140
91
141
steps :
92
142
- name : Checkout
93
- uses : actions/checkout@v2
143
+ uses : actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # tag=v3.0.0
94
144
95
- - name : Docker Build
96
- uses : docker/build-push-action@v1
145
+ - name : Docker meta
146
+ id : meta
147
+ uses : docker/metadata-action@e5622373a38e60fb6d795a4421e56882f2d7a681 # tag=v3.6.2
148
+ with :
149
+ images : ${{ github.repository }}
150
+ tags : |
151
+ type=schedule
152
+ type=ref,event=branch
153
+ type=ref,event=pr
154
+ type=semver,pattern={{version}}
155
+ type=semver,pattern={{major}}.{{minor}}
156
+ type=semver,pattern={{major}}
157
+ type=sha
158
+ type=raw,value=latest
159
+
160
+ - name : Set up QEMU
161
+ uses : docker/setup-qemu-action@27d0a4f181a40b142cce983c5393082c365d1480 # tag=v1.2.0
162
+
163
+ - name : Set up Docker Buildx
164
+ uses : docker/setup-buildx-action@94ab11c41e45d028884a99163086648e898eed25 # tag=v1.6.0
165
+
166
+ - name : Login to DockerHub
167
+ uses : docker/login-action@dd4fa0671be5250ee6f50aedf4cb05514abda2c7 # tag=v1.14.1
97
168
with :
98
169
username : ${{ secrets.DOCKER_USERNAME }}
99
170
password : ${{ secrets.DOCKER_PASSWORD }}
100
- repository : timoa/nodejs-encryption-api-example
101
- tags : latest
102
171
172
+ - name : Build and push
173
+ uses : docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a # tag=v2.10.0
174
+ with :
175
+ context : .
176
+ push : true
177
+ tags : ${{ steps.meta.outputs.tags }}
178
+ labels : ${{ steps.meta.outputs.labels }}
0 commit comments