Skip to content

Commit 0dec086

Browse files
committed
Enhancement: Simplify CI workflow by removing unused steps and adding security analysis job
Signed-off-by: Ihor Dvoretskyi <[email protected]>
1 parent ee07d0b commit 0dec086

File tree

2 files changed

+87
-63
lines changed

2 files changed

+87
-63
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,12 @@ on:
88

99
permissions:
1010
contents: read
11-
security-events: write
1211
actions: read
1312

1413
jobs:
1514
build:
1615
runs-on: ubuntu-latest
1716
name: Build and Validate
18-
outputs:
19-
image-name: ${{ steps.build.outputs.image-name }}
2017
steps:
2118
- name: Checkout
2219
uses: actions/checkout@v4
@@ -41,21 +38,8 @@ jobs:
4138
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4239

4340
- name: Build Docker image
44-
id: build
4541
run: |
46-
IMAGE_NAME="dev-template:${{ github.sha }}"
47-
docker build -t "$IMAGE_NAME" .devcontainer/
48-
echo "image-name=$IMAGE_NAME" >> $GITHUB_OUTPUT
49-
50-
- name: Save Docker image as artifact
51-
run: |
52-
docker save ${{ steps.build.outputs.image-name }} | gzip > dev-template.tar.gz
53-
54-
- name: Upload Docker image artifact
55-
uses: actions/upload-artifact@v4
56-
with:
57-
name: docker-image
58-
path: dev-template.tar.gz
42+
docker build -t dev-template:latest .devcontainer/
5943
6044
test:
6145
runs-on: ubuntu-latest
@@ -87,49 +71,4 @@ jobs:
8771
which npm || echo "npm is missing"
8872
# Test essential packages
8973
curl --version
90-
jq --version
91-
92-
security-scan:
93-
runs-on: ubuntu-latest
94-
name: Security and SBOM Analysis
95-
needs: build
96-
steps:
97-
- name: Checkout
98-
uses: actions/checkout@v4
99-
100-
- name: Download Docker image artifact
101-
uses: actions/download-artifact@v4
102-
with:
103-
name: docker-image
104-
105-
- name: Load Docker image
106-
run: |
107-
docker load < dev-template.tar.gz
108-
109-
- name: Run Trivy vulnerability scanner
110-
uses: aquasecurity/trivy-action@master
111-
with:
112-
image-ref: '${{ needs.build.outputs.image-name }}'
113-
format: 'sarif'
114-
output: 'trivy-results.sarif'
115-
116-
- name: Upload Trivy scan results to GitHub Security tab
117-
uses: github/codeql-action/upload-sarif@v3
118-
if: always()
119-
with:
120-
sarif_file: 'trivy-results.sarif'
121-
env:
122-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
123-
124-
- name: Generate SBOM
125-
uses: anchore/sbom-action@v0
126-
with:
127-
image: '${{ needs.build.outputs.image-name }}'
128-
format: 'spdx-json'
129-
output-file: 'sbom.spdx.json'
130-
131-
- name: Upload SBOM as artifact
132-
uses: actions/upload-artifact@v4
133-
with:
134-
name: sbom
135-
path: sbom.spdx.json
74+
jq --version

.github/workflows/security.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Security Analysis
2+
3+
on:
4+
schedule:
5+
# Run security scans daily at 2 AM UTC
6+
- cron: '0 2 * * *'
7+
push:
8+
branches: [ main ]
9+
paths:
10+
- '.devcontainer/**'
11+
- 'Dockerfile'
12+
- '.github/workflows/security.yml'
13+
pull_request:
14+
branches: [ main ]
15+
paths:
16+
- '.devcontainer/**'
17+
- 'Dockerfile'
18+
- '.github/workflows/security.yml'
19+
workflow_dispatch: # Allow manual trigger
20+
21+
permissions:
22+
contents: read
23+
security-events: write
24+
25+
jobs:
26+
security-scan:
27+
runs-on: ubuntu-latest
28+
name: Security and SBOM Analysis
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
33+
- name: Install missing dependencies
34+
run: sudo apt-get update && sudo apt-get install -y tcl
35+
36+
- name: Build Docker image for scanning
37+
run: |
38+
IMAGE_NAME="dev-template:${{ github.sha }}"
39+
docker build -t "$IMAGE_NAME" .devcontainer/
40+
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
41+
42+
- name: Run Trivy vulnerability scanner
43+
uses: aquasecurity/trivy-action@master
44+
with:
45+
image-ref: '${{ env.IMAGE_NAME }}'
46+
format: 'sarif'
47+
output: 'trivy-results.sarif'
48+
49+
- name: Upload Trivy scan results to GitHub Security tab
50+
uses: github/codeql-action/upload-sarif@v3
51+
if: always()
52+
with:
53+
sarif_file: 'trivy-results.sarif'
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
57+
- name: Generate SBOM
58+
uses: anchore/sbom-action@v0
59+
with:
60+
image: '${{ env.IMAGE_NAME }}'
61+
format: 'spdx-json'
62+
output-file: 'sbom.spdx.json'
63+
64+
- name: Upload SBOM as artifact
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: sbom-${{ github.sha }}
68+
path: sbom.spdx.json
69+
retention-days: 30
70+
71+
- name: Run Trivy filesystem scan
72+
uses: aquasecurity/trivy-action@master
73+
with:
74+
scan-type: 'fs'
75+
scan-ref: '.'
76+
format: 'sarif'
77+
output: 'trivy-fs-results.sarif'
78+
79+
- name: Upload filesystem scan results
80+
uses: github/codeql-action/upload-sarif@v3
81+
if: always()
82+
with:
83+
sarif_file: 'trivy-fs-results.sarif'
84+
env:
85+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)