Skip to content

Commit cd9bc5b

Browse files
authored
fix: correct cache-from for ECR builds, make container scan optional (#36)
* fix: correct cache-from for ECR builds * fix: correct cache-from for ECR builds * fix: disable containerscan temporary for ecr-single * fix: disable containerscan temporary for ecr-single * fix: linted, updated packages * fix: make container scan toggable * fix: moved variable to context * fix: pipeline ref updated * Update .github/workflows/kubernetes.yaml
1 parent 6641465 commit cd9bc5b

3 files changed

Lines changed: 51 additions & 34 deletions

File tree

.github/workflows/build-image.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ on:
4242
description: The kind of repository (github or ecr)
4343
default: "github"
4444
type: string
45+
enableContainerScan:
46+
required: false
47+
description: Apply the container scan
48+
default: true
49+
type: boolean
4550
runner:
4651
required: false
4752
description: Runner type
@@ -106,6 +111,7 @@ jobs:
106111
${{ inputs.registryHostname }}/${{ inputs.registryOrg }}/${{ github.event.deployment.payload.name }}:${{ inputs.version }}
107112
${{ inputs.registryHostname }}/${{ inputs.registryOrg }}/${{ github.event.deployment.payload.name }}:${{ github.sha }}
108113
- name: Scan for vulnerabilities
114+
if: inputs.enableContainerScan
109115
uses: crazy-max/ghaction-container-scan@v3
110116
with:
111117
image: ${{ inputs.registryHostname }}/${{ inputs.registryOrg }}/${{ github.event.deployment.payload.name }}:latest
@@ -166,7 +172,7 @@ jobs:
166172
APP_NAME=${{ github.event.deployment.payload.name }}
167173
ENVIRONMENT=${{ github.event.deployment.payload.env }}
168174
NPM_GITHUB_TOKEN=${{ secrets.npmGithubReadToken }}
169-
cache-from: type=registry,ref=${{ inputs.registryHostname }}/${{ inputs.registryOrg }}/${{ github.event.deployment.payload.name }}
175+
cache-from: type=registry,ref=${{ inputs.registryHostname }}/${{ github.event.deployment.payload.name }}
170176
cache-to: type=inline
171177
context: ${{ github.event.deployment.payload.container.context }}
172178
load: true
@@ -177,7 +183,7 @@ jobs:
177183
${{ steps.login-ecr.outputs.registry }}/${{ github.event.deployment.payload.name }}:${{ inputs.version }}
178184
${{ steps.login-ecr.outputs.registry }}/${{ github.event.deployment.payload.name }}:${{ github.sha }}
179185
- name: Scan for vulnerabilities
180-
if: inputs.repository_kind == 'ecr'
186+
if: inputs.enableContainerScan
181187
uses: crazy-max/ghaction-container-scan@v3
182188
with:
183189
image: ${{ steps.login-ecr.outputs.registry }}/${{ github.event.deployment.payload.name }}:latest
@@ -245,6 +251,7 @@ jobs:
245251
target: ${{ matrix.containerfile_targets }}
246252
- name: Scan for vulnerabilities
247253
uses: crazy-max/ghaction-container-scan@v3
254+
if: inputs.enableContainerScan
248255
with:
249256
image: ${{ inputs.registryHostname }}/${{ inputs.registryOrg }}/${{ github.event.deployment.payload.name }}-${{ matrix.containerfile_targets }}:latest
250257
dockerfile: Containerfile
@@ -306,7 +313,7 @@ jobs:
306313
APP_NAME=${{ github.event.deployment.payload.name }}
307314
ENVIRONMENT=${{ github.event.deployment.payload.env }}
308315
NPM_GITHUB_TOKEN=${{ secrets.npmGithubReadToken }}
309-
cache-from: type=registry,ref=${{ inputs.registryHostname }}/${{ inputs.registryOrg }}/${{ github.event.deployment.payload.name }}
316+
cache-from: type=registry,ref=${{ inputs.registryHostname }}/${{ github.event.deployment.payload.name }}
310317
cache-to: type=inline
311318
context: ${{ github.event.deployment.payload.container.context }}
312319
load: true
@@ -318,6 +325,7 @@ jobs:
318325
${{ steps.login-ecr.outputs.registry }}/${{ github.event.deployment.payload.name }}-${{ matrix.containerfile_targets }}:${{ github.sha }}
319326
target: ${{ matrix.containerfile_targets }}
320327
- name: Scan for vulnerabilities
328+
if: inputs.enableContainerScan
321329
uses: crazy-max/ghaction-container-scan@v3
322330
with:
323331
image: ${{ steps.login-ecr.outputs.registry }}/${{ github.event.deployment.payload.name }}-${{ matrix.containerfile_targets }}:latest

.github/workflows/kubernetes.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ on:
5757
description: The kind of repository (github or ecr)
5858
default: "github"
5959
type: string
60+
enableContainerScan:
61+
required: false
62+
description: Apply the container scan
63+
default: true
64+
type: boolean
6065
runner:
6166
required: false
6267
description: Runner type
@@ -183,6 +188,7 @@ jobs:
183188
registryOrg: ${{ inputs.registryOrg }}
184189
registryUsername: ${{ inputs.registryUsername }}
185190
repository_kind: ${{ inputs.repository_kind }}
191+
enableContainerScan: ${{ inputs.enableContainerScan }}
186192
runner: ${{ inputs.runner }}
187193
version: ${{ needs.initialize.outputs.version }}
188194
secrets: inherit

package-lock.json

Lines changed: 34 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)