Skip to content

Commit ba63d0a

Browse files
committed
Optimize Docker Security Scanning using matrix strategy
- Refactor Docker security scanning workflow to use matrix strategy for multiple images - Remove duplicate build and scan steps for different Docker images - Use dynamic service names and paths in workflow steps - Remove ENV file containing SSH key
1 parent 55144a1 commit ba63d0a

2 files changed

Lines changed: 18 additions & 33 deletions

File tree

.github/workflows/code-quality.yml

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -45,51 +45,40 @@ jobs:
4545
name: Docker Security Scanning
4646
runs-on: ubuntu-latest
4747
needs: hadolint
48+
strategy:
49+
matrix:
50+
service:
51+
- name: n8n
52+
dockerfile: Dockerfile.n8n
53+
tag: n8n-test:latest
54+
- name: temporal
55+
dockerfile: Dockerfile.temporal
56+
tag: temporal-test:latest
4857
steps:
4958
- name: Checkout code
5059
uses: actions/checkout@v4
5160
- name: Set up Docker Buildx
5261
uses: docker/setup-buildx-action@v3
53-
- name: Build n8n image
62+
- name: Build ${{ matrix.service.name }} image
5463
uses: docker/build-push-action@v5
5564
with:
5665
context: .
57-
file: Dockerfile.n8n
66+
file: ${{ matrix.service.dockerfile }}
5867
push: false
59-
tags: n8n-test:latest
68+
tags: ${{ matrix.service.tag }}
6069
load: true
61-
- name: Build temporal image
62-
uses: docker/build-push-action@v5
63-
with:
64-
context: .
65-
file: Dockerfile.temporal
66-
push: false
67-
tags: temporal-test:latest
68-
load: true
69-
- name: Scan n8n image
70+
- name: Scan ${{ matrix.service.name }} image
7071
uses: docker/scout-action@v1
7172
with:
7273
command: cves
73-
image: n8n-test:latest
74-
sarif-file: n8n-scan.sarif
74+
image: ${{ matrix.service.tag }}
75+
sarif-file: ${{ matrix.service.name }}-scan.sarif
7576
github-token: ${{ secrets.GITHUB_TOKEN }}
76-
- name: Scan temporal image
77-
uses: docker/scout-action@v1
78-
with:
79-
command: cves
80-
image: temporal-test:latest
81-
sarif-file: temporal-scan.sarif
82-
github-token: ${{ secrets.GITHUB_TOKEN }}
83-
- name: Upload n8n scan results
84-
uses: github/codeql-action/upload-sarif@v2
85-
with:
86-
sarif_file: n8n-scan.sarif
87-
category: n8n
88-
- name: Upload temporal scan results
77+
- name: Upload ${{ matrix.service.name }} scan results
8978
uses: github/codeql-action/upload-sarif@v2
9079
with:
91-
sarif_file: temporal-scan.sarif
92-
category: temporal
80+
sarif_file: ${{ matrix.service.name }}-scan.sarif
81+
category: ${{ matrix.service.name }}
9382

9483
service-check:
9584
name: Service Availability Check

ENV

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)