20
20
contents : read
21
21
pull-requests : write
22
22
security-events : write
23
+ env :
24
+ PR_HEAD_SHA : ${{ github.event.pull_request.head.sha }}
25
+ GITHUB_REF_NAME : ${{ github.ref_name }}
26
+ QUAY_RELEASE_REPO : ${{ vars.QUAY_RELEASE_REPO }}
27
+ GITHUB_REF : ${{ github.ref }}
28
+ GITHUB_HEAD_REF : ${{ github.head_ref }}
23
29
steps : # Assign context variable for various action contexts (tag, main, CI)
24
30
- name : Assigning CI context
25
31
if : github.head_ref != '' && github.head_ref != 'main' && !startsWith(github.ref, 'refs/tags/v')
@@ -48,51 +54,59 @@ jobs:
48
54
# Print variables for debugging
49
55
- name : Log reference variables
50
56
run : |
51
- echo "CONTEXT: ${{ env.BUILD_CONTEXT }}"
52
- echo "GITHUB.REF: ${{ github.ref }}"
53
- echo "GITHUB.HEAD_REF: ${{ github.head_ref }}"
54
- echo "SHA: ${{ github.event.pull_request.head.sha }}"
55
- echo "MAIN IMAGE AT: ${{ vars.QUAY_RELEASE_REPO }}:latest"
56
- echo "CI IMAGE AT: quay.io/trustyai/guardrails-detector-huggingface-runtime-ci:${{ github.event.pull_request.head.sha }}"
57
- echo "Built-In Detector CI IMAGE AT: quay.io/trustyai/guardrails-detector-built-in-ci:${{ github.event.pull_request.head.sha }}"
57
+ echo "CONTEXT: $BUILD_CONTEXT"
58
+ echo "GITHUB.REF: $GITHUB_REF"
59
+ echo "GITHUB.HEAD_REF: $GITHUB_HEAD_REF"
60
+ echo "SHA: $PR_HEAD_SHA"
61
+ echo "MAIN IMAGE AT: $QUAY_RELEASE_REPO:latest"
62
+ echo "CI IMAGE AT: quay.io/trustyai/guardrails-detector-huggingface-runtime-ci:$PR_HEAD_SHA"
63
+ echo "Built-In Detector CI IMAGE AT: quay.io/trustyai/guardrails-detector-built-in-ci:$PR_HEAD_SHA"
64
+ echo "LLM Judge CI IMAGE AT: quay.io/trustyai/guardrails-detector-llm-judge-ci:$PR_HEAD_SHA"
58
65
59
66
# Set environments depending on context
60
67
- name : Set CI environment
61
68
if : env.BUILD_CONTEXT == 'ci'
62
69
run : |
63
- echo "TAG=${{ github.event.pull_request.head.sha }} " >> $GITHUB_ENV
70
+ echo "TAG=$PR_HEAD_SHA " >> $GITHUB_ENV
64
71
echo "IMAGE_NAME=quay.io/trustyai/guardrails-detector-huggingface-runtime-ci" >> $GITHUB_ENV
65
72
echo "BUILTIN_IMAGE_NAME=quay.io/trustyai/guardrails-detector-built-in-ci" >> $GITHUB_ENV
73
+ echo "LLM_JUDGE_IMAGE_NAME=quay.io/trustyai/guardrails-detector-llm-judge-ci" >> $GITHUB_ENV
74
+ echo "EXPIRY_LABEL=--label quay.expires-after=7d" >> $GITHUB_ENV
66
75
- name : Set main-branch environment
67
76
if : env.BUILD_CONTEXT == 'main'
68
77
run : |
69
78
echo "TAG=latest" >> $GITHUB_ENV
70
- echo "IMAGE_NAME=${{ vars. QUAY_RELEASE_REPO }} " >> $GITHUB_ENV
79
+ echo "IMAGE_NAME=$QUAY_RELEASE_REPO" >> $GITHUB_ENV
71
80
echo "BUILTIN_IMAGE_NAME=quay.io/trustyai/guardrails-detector-built-in" >> $GITHUB_ENV
81
+ echo "LLM_JUDGE_IMAGE_NAME=quay.io/trustyai/guardrails-detector-llm-judge" >> $GITHUB_ENV
82
+ echo "EXPIRY_LABEL=" >> $GITHUB_ENV
72
83
- name : Set tag environment
73
84
if : env.BUILD_CONTEXT == 'tag'
74
85
run : |
75
- echo "TAG=${{ github.ref_name }} " >> $GITHUB_ENV
76
- echo "IMAGE_NAME=${{ vars. QUAY_RELEASE_REPO }} " >> $GITHUB_ENV
86
+ echo "TAG=$GITHUB_REF_NAME " >> $GITHUB_ENV
87
+ echo "IMAGE_NAME=$QUAY_RELEASE_REPO" >> $GITHUB_ENV
77
88
echo "BUILTIN_IMAGE_NAME=quay.io/trustyai/guardrails-detector-built-in" >> $GITHUB_ENV
89
+ echo "LLM_JUDGE_IMAGE_NAME=quay.io/trustyai/guardrails-detector-llm-judge" >> $GITHUB_ENV
90
+ echo "EXPIRY_LABEL=" >> $GITHUB_ENV
78
91
#
79
92
# Run docker commands
80
- - name : Put expiry date on CI-tagged image
81
- if : env.BUILD_CONTEXT == 'ci'
82
- run : |
83
- echo 'LABEL quay.expires-after=7d#' >> detectors/Dockerfile.hf
84
- echo 'LABEL quay.expires-after=7d#' >> detectors/Dockerfile.builtIn
85
93
- name : Build image
86
- run : docker build -t ${{ env. IMAGE_NAME }} :$TAG -f detectors/Dockerfile.hf detectors
94
+ run : docker build -t "$ IMAGE_NAME:$TAG" $EXPIRY_LABEL -f detectors/Dockerfile.hf detectors
87
95
- name : Log in to Quay
88
- run : docker login -u ${{ secrets.QUAY_ROBOT_USERNAME }} -p ${{ secrets.QUAY_ROBOT_SECRET }} quay.io
96
+ env :
97
+ QUAY_ROBOT_USERNAME : ${{ secrets.QUAY_ROBOT_USERNAME }}
98
+ QUAY_ROBOT_SECRET : ${{ secrets.QUAY_ROBOT_SECRET }}
99
+ run : docker login -u "$QUAY_ROBOT_USERNAME" -p "$QUAY_ROBOT_SECRET" quay.io
89
100
- name : Push to Quay CI repo
90
- run : docker push ${{ env. IMAGE_NAME }} :$TAG
101
+ run : docker push "$ IMAGE_NAME:$TAG"
91
102
- name : Build built-in detector image
92
- run : docker build -t ${{ env. BUILTIN_IMAGE_NAME }} :$TAG -f detectors/Dockerfile.builtIn detectors
103
+ run : docker build -t "$ BUILTIN_IMAGE_NAME:$TAG" $EXPIRY_LABEL -f detectors/Dockerfile.builtIn detectors
93
104
- name : Push to Quay CI repo
94
- run : docker push ${{ env.BUILTIN_IMAGE_NAME }}:$TAG
95
-
105
+ run : docker push "$BUILTIN_IMAGE_NAME:$TAG"
106
+ - name : Build LLM Judge detector image
107
+ run : docker build -t "$LLM_JUDGE_IMAGE_NAME:$TAG" $EXPIRY_LABEL -f detectors/Dockerfile.judge detectors
108
+ - name : Push LLM Judge image to Quay CI repo
109
+ run : docker push "$LLM_JUDGE_IMAGE_NAME:$TAG"
96
110
# Leave comment
97
111
- uses : peter-evans/find-comment@v3
98
112
name : Find Comment
@@ -112,8 +126,9 @@ jobs:
112
126
body : |
113
127
PR image build completed successfully!
114
128
115
- 📦 [PR image](https://quay.io/repository/trustyai/guardrails-detector-huggingface-runtime-ci?tab=tags): `quay.io/trustyai/guardrails-detector-huggingface-runtime-ci:${{ github.event.pull_request.head.sha }}`
116
- 📦 [PR image](https://quay.io/trustyai/guardrails-detector-built-in-ci?tab=tags): `quay.io/trustyai/guardrails-detector-built-in-ci:${{ github.event.pull_request.head.sha }}`
129
+ 📦 [Huggingface PR image](https://quay.io/repository/trustyai/guardrails-detector-huggingface-runtime-ci?tab=tags): `quay.io/trustyai/guardrails-detector-huggingface-runtime-ci:$PR_HEAD_SHA`
130
+ 📦 [Built-in PR image](https://quay.io/trustyai/guardrails-detector-built-in-ci?tab=tags): `quay.io/trustyai/guardrails-detector-built-in-ci:$PR_HEAD_SHA`
131
+ 📦 [LLM Judge PR image](https://quay.io/trustyai/guardrails-detector-llm-judge-ci?tab=tags): `quay.io/trustyai/guardrails-detector-llm-judge-ci:$PR_HEAD_SHA`
117
132
- name : Trivy scan
118
133
uses :
aquasecurity/[email protected]
119
134
with :
@@ -136,6 +151,17 @@ jobs:
136
151
exit-code : ' 0'
137
152
ignore-unfixed : false
138
153
vuln-type : ' os,library'
154
+ - name : Trivy scan, LLM Judge image
155
+ uses :
aquasecurity/[email protected]
156
+ with :
157
+ scan-type : ' image'
158
+ image-ref : " ${{ env.LLM_JUDGE_IMAGE_NAME }}:${{ env.TAG }}"
159
+ format : ' sarif'
160
+ output : ' trivy-results-llm-judge.sarif'
161
+ severity : ' MEDIUM,HIGH,CRITICAL'
162
+ exit-code : ' 0'
163
+ ignore-unfixed : false
164
+ vuln-type : ' os,library'
139
165
- name : Update Security tab - Huggingface
140
166
uses : github/codeql-action/upload-sarif@v3
141
167
with :
@@ -146,3 +172,8 @@ jobs:
146
172
with :
147
173
sarif_file : ' trivy-results-built-in.sarif'
148
174
category : built-in
175
+ - name : Update Security tab - LLM Judge
176
+ uses : github/codeql-action/upload-sarif@v3
177
+ with :
178
+ sarif_file : ' trivy-results-llm-judge.sarif'
179
+ category : llm-judge
0 commit comments