Skip to content

Commit 7bfab4e

Browse files
committed
security(trivy): build, deploy
1 parent 38014c0 commit 7bfab4e

File tree

2 files changed

+31
-45
lines changed

2 files changed

+31
-45
lines changed

.github/workflows/build_and_deploy.yml

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and deploy
1+
name: Build, scan images and deploy
22

33
on:
44
push:
@@ -8,13 +8,10 @@ on:
88
types:
99
- published
1010
- edited
11-
workflow_dispatch: # Add this to allow manual triggering
12-
pull_request:
13-
branches:
14-
- main
11+
workflow_dispatch:
1512

1613
jobs:
17-
build-api:
14+
build-opengatellm-api:
1815
name: Build and push OpenGateLLM API image
1916
runs-on: ubuntu-latest
2017
env:
@@ -126,12 +123,12 @@ jobs:
126123
matrix:
127124
environment: [dev, staging, prod]
128125
include:
129-
- environment: prod
130-
url: https://albert.playground.etalab.gouv.fr
131-
- environment: staging
132-
url: https://albert.playground.staging.etalab.gouv.fr
133126
- environment: dev
134127
url: https://albert.playground.dev.etalab.gouv.fr
128+
- environment: staging
129+
url: https://albert.playground.staging.etalab.gouv.fr
130+
- environment: prod
131+
url: https://albert.playground.etalab.gouv.fr
135132
steps:
136133
- name: Checkout repository
137134
uses: actions/checkout@v4
@@ -164,29 +161,37 @@ jobs:
164161

165162
trivy-scan-api:
166163
name: Trivy scan — API
167-
needs: build-api
164+
needs: build-opengatellm-api
168165
uses: ./.github/workflows/trivy-scan.yml
169166
with:
170167
image-name: ghcr.io/etalab-ia/opengatellm/api
171168
image-tag: ${{ github.event_name == 'release' && github.event.release.tag_name || 'latest' }}
172-
category-prefix: trivy-api
169+
170+
trivy-scan-playground:
171+
name: Trivy scan — Playground
172+
needs: build-opengatellm-playground
173+
uses: ./.github/workflows/trivy-scan.yml
174+
with:
175+
image-name: ghcr.io/etalab-ia/opengatellm/playground
176+
image-tag: ${{ github.event_name == 'release' && github.event.release.tag_name || 'latest' }}
173177

174178
deploy-dev:
175179
if: github.event_name == 'push' # Only deploy on push to main
176180
name: Deploy from ${{ github.ref_name }}/${{ github.sha }}
177181
runs-on: ubuntu-latest
178182
needs:
179-
- build-api
183+
- build-opengatellm-api
180184
- build-opengatellm-playground
181185
- build-albert-playground
182186
- trivy-scan-api
187+
- trivy-scan-playground
183188
steps:
184189
- name: Trigger dev deployment
185190
run: |
186191
RESPONSE="$(curl --request POST \
187192
--form token=${{ secrets.GITLAB_CI_TOKEN }} \
188193
--form ref=main \
189-
--form 'variables[pipeline_name]=${{ github.event.repository.name }} - ${{ needs.build-api.outputs.commit_title }}' \
194+
--form 'variables[pipeline_name]=${{ github.event.repository.name }} - ${{ needs.build-opengatellm-api.outputs.commit_title }}' \
190195
--form 'variables[docker_image_tag]=latest' \
191196
--form 'variables[application_to_deploy]=albert-api' \
192197
--form 'variables[deployment_environment]=dev' \

.github/workflows/trivy-scan.yml

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,56 +11,37 @@ on:
1111
description: "Image tag to scan"
1212
required: true
1313
type: string
14-
category-prefix:
15-
description: "Prefix for SARIF category (ex: trivy-api)"
16-
required: true
17-
type: string
1814

1915
jobs:
2016
trivy-scan:
21-
name: Trivy scan — ${{ inputs.category-prefix }}
2217
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
security-events: write
2321
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
2425
- name: Log in to GitHub Container Registry
2526
uses: docker/login-action@v3
2627
with:
2728
registry: ghcr.io
2829
username: ${{ github.actor }}
2930
password: ${{ secrets.GITHUB_TOKEN }}
3031

31-
# HIGH → notifie sans bloquer
3232
- name: Trivy scan (HIGH — warning)
33-
if: always()
34-
uses: aquasecurity/trivy-action@master
33+
uses: aquasecurity/trivy-action@v0.35.0
3534
with:
3635
image-ref: ${{ inputs.image-name }}:${{ inputs.image-tag }}
37-
format: sarif
38-
output: trivy-high.sarif
39-
severity: HIGH
36+
format: 'table'
37+
severity: 'HIGH'
4038
exit-code: "0"
41-
ignore-unfixed: true
42-
43-
- name: Upload HIGH results to GitHub Security
44-
uses: github/codeql-action/upload-sarif@v4
45-
if: always()
46-
with:
47-
sarif_file: trivy-high.sarif
48-
category: ${{ inputs.category-prefix }}-high
4939

5040
# CRITICAL → bloque le pipeline
5141
- name: Trivy scan (CRITICAL — blocking)
52-
uses: aquasecurity/trivy-action@master
42+
uses: aquasecurity/trivy-action@v0.35.0
5343
with:
5444
image-ref: ${{ inputs.image-name }}:${{ inputs.image-tag }}
55-
format: sarif
56-
output: trivy-critical.sarif
57-
severity: CRITICAL
45+
format: 'table'
46+
severity: 'CRITICAL'
5847
exit-code: "1"
59-
ignore-unfixed: true
60-
61-
- name: Upload CRITICAL results to GitHub Security
62-
uses: github/codeql-action/upload-sarif@v4
63-
if: always()
64-
with:
65-
sarif_file: trivy-critical.sarif
66-
category: ${{ inputs.category-prefix }}-critical

0 commit comments

Comments
 (0)