Skip to content
This repository was archived by the owner on Aug 25, 2025. It is now read-only.

Commit c2bb184

Browse files
authored
Merge pull request #66 from davidnixon/chore-add-trivy
chore: add Trivy scanner
2 parents f4d8e21 + 7acfcb0 commit c2bb184

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

.github/workflows/trivy.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Scan deployed images with Trivy
2+
3+
# Controls when the action will run.
4+
on:
5+
#schedule:
6+
# At 12:29 on day-of-month 8
7+
# - cron: '29 12 8 * *'
8+
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Install IBM Cloud CLI
18+
run: curl -fsSL https://clis.cloud.ibm.com/install/linux | sh
19+
20+
- name: Install IBM cloud plugins
21+
run: |
22+
ibmcloud plugin install code-engine
23+
ibmcloud plugin install container-registry
24+
25+
- name: Show IBM CLI version
26+
run: ibmcloud -v
27+
28+
- name: Login to IBM Cloud
29+
env:
30+
IBM_CLOUD_APIKEY: ${{ secrets.IBM_CLOUD_APIKEY }}
31+
IBM_CLOUD_GROUP: ${{ vars.IBM_CLOUD_GROUP }}
32+
IBM_REGION: ${{ vars.IBM_REGION }}
33+
IBM_CR_REGION: ${{ vars.IBM_CR_REGION }}
34+
run: |
35+
ibmcloud login --apikey ${IBM_CLOUD_APIKEY} -g ${IBM_CLOUD_GROUP} -r ${IBM_REGION}
36+
ibmcloud cr region-set ${IBM_CR_REGION}
37+
ibmcloud cr login
38+
39+
- name: Select the project
40+
env:
41+
CE_PROJECT: ${{ vars.CE_PROJECT }}
42+
run: ibmcloud ce project select --name ${CE_PROJECT}
43+
44+
- name: Get deployed image
45+
id: image
46+
env:
47+
CE_APP_NAME: ${{ vars.CE_APP_NAME }}
48+
run: echo "IMAGE=$(ibmcloud ce app get --output json --name ${CE_APP_NAME} | jq -r '.spec.template.spec.containers[0].image[8:]')" >> "$GITHUB_OUTPUT"
49+
50+
- name: Run Trivy vulnerability scanner
51+
uses: aquasecurity/trivy-action@0.28.0
52+
with:
53+
image-ref: '${{ steps.image.outputs.IMAGE }}'
54+
format: 'sarif'
55+
output: 'trivy-results.sarif'
56+
57+
- name: Upload Trivy scan results to GitHub Security tab
58+
uses: github/codeql-action/upload-sarif@v3
59+
with:
60+
sarif_file: 'trivy-results.sarif'

0 commit comments

Comments
 (0)