Skip to content

Commit 50f1c3e

Browse files
committed
Add built-in detectors to GH actions
1 parent 1b44c64 commit 50f1c3e

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

.github/workflows/build-and-push-hf.yaml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,34 +55,44 @@ jobs:
5555
echo "SHA: ${{ github.event.pull_request.head.sha }}"
5656
echo "MAIN IMAGE AT: ${{ vars.QUAY_RELEASE_REPO }}:latest"
5757
echo "CI IMAGE AT: quay.io/trustyai/guardrails-detector-huggingface-runtime-ci:${{ github.event.pull_request.head.sha }}"
58+
echo "Built-In Detector CI IMAGE AT: quay.io/trustyai/regex-detector-ci:${{ github.event.pull_request.head.sha }}"
5859
5960
# Set environments depending on context
6061
- name: Set CI environment
6162
if: env.BUILD_CONTEXT == 'ci'
6263
run: |
6364
echo "TAG=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
6465
echo "IMAGE_NAME=quay.io/trustyai/guardrails-detector-huggingface-runtime-ci" >> $GITHUB_ENV
66+
echo "BUILTIN_IMAGE_NAME=quay.io/trustyai/regex-detector-ci" >> $GITHUB_ENV
6567
- name: Set main-branch environment
6668
if: env.BUILD_CONTEXT == 'main'
6769
run: |
6870
echo "TAG=latest" >> $GITHUB_ENV
6971
echo "IMAGE_NAME=${{ vars.QUAY_RELEASE_REPO }}" >> $GITHUB_ENV
72+
echo "BUILTIN_IMAGE_NAME=quay.io/trustyai/regex-detector" >> $GITHUB_ENV
7073
- name: Set tag environment
7174
if: env.BUILD_CONTEXT == 'tag'
7275
run: |
7376
echo "TAG=${{ github.ref_name }}" >> $GITHUB_ENV
7477
echo "IMAGE_NAME=${{ vars.QUAY_RELEASE_REPO }}" >> $GITHUB_ENV
78+
echo "BUILTIN_IMAGE_NAME=quay.io/trustyai/regex-detector" >> $GITHUB_ENV
7579
#
7680
# Run docker commands
7781
- name: Put expiry date on CI-tagged image
7882
if: env.BUILD_CONTEXT == 'ci'
79-
run: echo 'LABEL quay.expires-after=7d#' >> detectors/Dockerfile.hf
83+
run: |
84+
echo 'LABEL quay.expires-after=7d#' >> detectors/Dockerfile.hf
85+
echo 'LABEL quay.expires-after=7d#' >> detectors/Dockerfile.builtIn
8086
- name: Build image
8187
run: docker build -t ${{ env.IMAGE_NAME }}:$TAG -f detectors/Dockerfile.hf detectors
8288
- name: Log in to Quay
8389
run: docker login -u ${{ secrets.QUAY_ROBOT_USERNAME }} -p ${{ secrets.QUAY_ROBOT_SECRET }} quay.io
8490
- name: Push to Quay CI repo
8591
run: docker push ${{ env.IMAGE_NAME }}:$TAG
92+
- name: Build built-in detector image
93+
run: docker build -t ${{ env.BUILTIN_IMAGE_NAME }}:$TAG -f detectors/Dockerfile.builtIn detectors
94+
- name: Push to Quay CI repo
95+
run: docker push ${{ env.BUILTIN_IMAGE_NAME }}:$TAG
8696

8797
# Leave comment
8898
- uses: peter-evans/find-comment@v3
@@ -104,6 +114,7 @@ jobs:
104114
PR image build completed successfully!
105115
106116
📦 [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 }}`
117+
📦 [PR image](https://quay.io/trustyai/regex-detector-ci?tab=tags): `quay.io/trustyai/regex-detector-ci:${{ github.event.pull_request.head.sha }}`
107118
- name: Trivy scan
108119
uses: aquasecurity/[email protected]
109120
with:
@@ -115,8 +126,22 @@ jobs:
115126
exit-code: '0'
116127
ignore-unfixed: false
117128
vuln-type: 'os,library'
118-
129+
- name: Trivy scan, built-in image
130+
uses: aquasecurity/[email protected]
131+
with:
132+
scan-type: 'image'
133+
image-ref: "${{ env.BUILTIN_IMAGE_NAME }}:${{ env.TAG }}"
134+
format: 'sarif'
135+
output: 'trivy-results-built-in.sarif'
136+
severity: 'MEDIUM,HIGH,CRITICAL'
137+
exit-code: '0'
138+
ignore-unfixed: false
139+
vuln-type: 'os,library'
119140
- name: Update Security tab
120141
uses: github/codeql-action/upload-sarif@v3
121142
with:
122143
sarif_file: 'trivy-results.sarif'
144+
- name: Update Security tab
145+
uses: github/codeql-action/upload-sarif@v3
146+
with:
147+
sarif_file: 'trivy-results-built-in.sarif'

0 commit comments

Comments
 (0)