14
14
DOCKER_REPOSITORY_COMMAND : aws-asg-tags-command
15
15
DOCKER_REPOSITORY_LAMBDA : aws-asg-tags-lambda
16
16
17
+ AWS_S3_REGION : ${{ secrets.AWS_S3_REGION }}
18
+ SBOM_FILENAME : docker-sbom
19
+ NOTION_DATABASE_ID : ${{ secrets.NOTION_REPOS_DATABASE_ID }}
20
+
17
21
18
22
19
23
permissions :
49
53
steps :
50
54
- name : Version
51
55
id : version
52
- run : echo ::set-output name= value:: ${GITHUB_REF#refs/*/}
56
+ run : echo " value= ${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
53
57
54
58
55
59
build-command :
@@ -69,21 +73,72 @@ jobs:
69
73
restore-keys : |
70
74
${{ runner.os }}-spm-
71
75
76
+ - name : Build Docker Image
77
+ id : docker_build
78
+ uses : docker/build-push-action@v3
79
+ env :
80
+ DOCKER_IMAGE_TAG : ${{ env.DOCKER_REPOSITORY_COMMAND }}:${{ needs.prepare.outputs.version }}
81
+ with :
82
+ context : .
83
+ file : command.Dockerfile
84
+ push : false
85
+ load : true
86
+ tags : ${{ env.DOCKER_IMAGE_TAG }}
87
+
88
+ - name : Create Docker SBOM
89
+ uses : anchore/sbom-action@v0
90
+ with :
91
+ image : ${{ steps.docker_build.outputs.imageId }}
92
+ format : spdx-json
93
+ upload-release-assets : false
94
+ output-file : ${{ env.SBOM_FILENAME }}.spdx.json
95
+
96
+ - name : Scan SBOM
97
+ id : scan_sbom
98
+ uses : anchore/scan-action@v3
99
+ with :
100
+ sbom : ${{ env.SBOM_FILENAME }}.spdx.json
101
+ output-format : sarif
102
+ fail-build : false
103
+
104
+ - name : Determine number of noticiable vulnerabilities
105
+ id : count_vulnerabilities
106
+ run : echo "value=$(grep -cE "(medium|high|critical) vulnerability" ${{ steps.scan_sbom.outputs.sarif }})" >> $GITHUB_OUTPUT
107
+
108
+ - name : Configure AWS credentials
109
+ uses : aws-actions/configure-aws-credentials@v1
110
+ with :
111
+ role-to-assume : ${{ secrets.AWS_S3_SBOMS_ROLE_ARN }}
112
+ aws-region : ${{ env.AWS_S3_REGION }}
113
+
114
+ - name : Copy SBOM to S3
115
+ run : |
116
+ aws s3 cp ${{ env.SBOM_FILENAME }}.spdx.json s3://repos-sboms/${{ github.event.repository.name }}/command-${{ env.SBOM_FILENAME }}.spdx.json
117
+ aws s3 cp ${{ steps.scan_sbom.outputs.sarif }} s3://repos-sboms/${{ github.event.repository.name }}/command-${{ env.SBOM_FILENAME }}-scan.sarif
118
+
119
+ - name : Update Notion Page
120
+ uses : ydataai/update-notion-page@v1
121
+ env :
122
+ STATUS_ICON : ${{ steps.count_vulnerabilities.outputs.value == '0' && '"✅"' || '"⚠️"' }}
123
+ STATUS_URL : ${{ steps.count_vulnerabilities.outputs.value == '0' && 'null' || format('{{"url":"https://s3.console.aws.amazon.com/s3/buckets/repos-sboms?region={0}&prefix={1}/{2}-{3}-scan.sarif"}}', env.AWS_S3_REGION, github.event.repository.name, 'manager', env.SBOM_FILENAME) }}
124
+ with :
125
+ notion_secret : ${{ secrets.NOTION_SECRET }}
126
+ notion_database_id : ${{ env.NOTION_DATABASE_ID }}
127
+ notion_database_query_filter : ' { "property": "Repo", "title": { "equals": "${{ github.event.repository.name }}" } }'
128
+ notion_page_update_properties : ' { "Docker Scan": { "rich_text": [ { "text": { "content": ${{ env.STATUS_ICON }}, "link": ${{ env.STATUS_URL }} } } ] }, "SBOMS": { "url": "https://s3.console.aws.amazon.com/s3/buckets/repos-sboms?region=${{ env.AWS_S3_REGION }}&prefix=${{ github.event.repository.name }}/" } }'
129
+
72
130
- name : Login to Dockerhub Registry
73
131
uses : docker/login-action@v2
74
132
with :
75
133
username : ${{ secrets.DOCKERHUB_USERNAME }}
76
134
password : ${{ secrets.DOCKERHUB_PASSWORD }}
77
135
78
- - name : Build and push docker image
79
- id : docker_build
80
- uses : docker/build-push-action@v3
136
+ - name : Push Docker Image
81
137
env :
82
138
DOCKER_IMAGE_TAG : ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKER_REPOSITORY_COMMAND }}:${{ needs.prepare.outputs.version }}
83
- with :
84
- file : command.Dockerfile
85
- push : true
86
- tags : ${{ env.DOCKER_IMAGE_TAG }}
139
+ run : |
140
+ docker tag ${{ steps.docker_build.outputs.imageId }} ${{ env.DOCKER_IMAGE_TAG }}
141
+ docker push ${{ env.DOCKER_IMAGE_TAG }}
87
142
88
143
89
144
build-lambda :
@@ -103,21 +158,66 @@ jobs:
103
158
restore-keys : |
104
159
${{ runner.os }}-spm-
105
160
161
+ - name : Build Docker Image
162
+ id : docker_build
163
+ uses : docker/build-push-action@v3
164
+ env :
165
+ DOCKER_IMAGE_TAG : ${{ env.DOCKER_REPOSITORY_LAMBDA }}:${{ needs.prepare.outputs.version }}
166
+ with :
167
+ context : .
168
+ file : lambda.Dockerfile
169
+ push : false
170
+ load : true
171
+ tags : ${{ env.DOCKER_IMAGE_TAG }}
172
+
173
+ - name : Create Docker SBOM
174
+ uses : anchore/sbom-action@v0
175
+ with :
176
+ image : ${{ steps.docker_build.outputs.imageId }}
177
+ format : spdx-json
178
+ upload-release-assets : false
179
+ output-file : ${{ env.SBOM_FILENAME }}.spdx.json
180
+
181
+ - name : Scan SBOM
182
+ id : scan_sbom
183
+ uses : anchore/scan-action@v3
184
+ with :
185
+ sbom : ${{ env.SBOM_FILENAME }}.spdx.json
186
+ output-format : sarif
187
+ fail-build : false
188
+
189
+ - name : Determine number of noticiable vulnerabilities
190
+ id : count_vulnerabilities
191
+ run : echo "value=$(grep -cE "(medium|high|critical) vulnerability" ${{ steps.scan_sbom.outputs.sarif }})" >> $GITHUB_OUTPUT
192
+
193
+ - name : Copy SBOM to S3
194
+ run : |
195
+ aws s3 cp ${{ env.SBOM_FILENAME }}.spdx.json s3://repos-sboms/${{ github.event.repository.name }}/lambda-${{ env.SBOM_FILENAME }}.spdx.json
196
+ aws s3 cp ${{ steps.scan_sbom.outputs.sarif }} s3://repos-sboms/${{ github.event.repository.name }}/lambda-${{ env.SBOM_FILENAME }}-scan.sarif
197
+
198
+ - name : Update Notion Page
199
+ uses : ydataai/update-notion-page@v1
200
+ env :
201
+ STATUS_ICON : ${{ steps.count_vulnerabilities.outputs.value == '0' && '"✅"' || '"⚠️"' }}
202
+ STATUS_URL : ${{ steps.count_vulnerabilities.outputs.value == '0' && 'null' || format('{{"url":"https://s3.console.aws.amazon.com/s3/buckets/repos-sboms?region={0}&prefix={1}/{2}-{3}-scan.sarif"}}', env.AWS_S3_REGION, github.event.repository.name, 'lambda', env.SBOM_FILENAME) }}
203
+ with :
204
+ notion_secret : ${{ secrets.NOTION_SECRET }}
205
+ notion_database_id : ${{ env.NOTION_DATABASE_ID }}
206
+ notion_database_query_filter : ' { "property": "Repo", "title": { "equals": "${{ github.event.repository.name }}" } }'
207
+ notion_page_update_properties : ' { "Docker Scan": { "rich_text": [ { "text": { "content": ${{ env.STATUS_ICON }}, "link": ${{ env.STATUS_URL }} } } ] }, "SBOMS": { "url": "https://s3.console.aws.amazon.com/s3/buckets/repos-sboms?region=${{ env.AWS_S3_REGION }}&prefix=${{ github.event.repository.name }}/" } }'
208
+
106
209
- name : Login to Dockerhub Registry
107
210
uses : docker/login-action@v2
108
211
with :
109
212
username : ${{ secrets.DOCKERHUB_USERNAME }}
110
213
password : ${{ secrets.DOCKERHUB_PASSWORD }}
111
214
112
- - name : Build and push docker image
113
- id : docker_build
114
- uses : docker/build-push-action@v3
215
+ - name : Push Docker Image
115
216
env :
116
217
DOCKER_IMAGE_TAG : ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKER_REPOSITORY_LAMBDA }}:${{ needs.prepare.outputs.version }}
117
- with :
118
- file : lambda.Dockerfile
119
- push : true
120
- tags : ${{ env.DOCKER_IMAGE_TAG }}
218
+ run : |
219
+ docker tag ${{ steps.docker_build.outputs.imageId }} ${{ env.DOCKER_IMAGE_TAG }}
220
+ docker push ${{ env.DOCKER_IMAGE_TAG }}
121
221
122
222
123
223
update-manifests :
0 commit comments