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')
47
53
#
48
54
# Print variables for debugging
49
55
- name : Log reference variables
50
- env :
51
- GITHUB_REF : ${{ github.ref }}
52
- GITHUB_HEAD_REF : ${{ github.head_ref }}
53
- PR_HEAD_SHA : ${{ github.event.pull_request.head.sha }}
54
- QUAY_RELEASE_REPO : ${{ vars.QUAY_RELEASE_REPO }}
55
56
run : |
56
57
echo "CONTEXT: $BUILD_CONTEXT"
57
58
echo "GITHUB.REF: $GITHUB_REF"
@@ -65,42 +66,32 @@ jobs:
65
66
# Set environments depending on context
66
67
- name : Set CI environment
67
68
if : env.BUILD_CONTEXT == 'ci'
68
- env :
69
- PR_HEAD_SHA : ${{ github.event.pull_request.head.sha }}
70
69
run : |
71
70
echo "TAG=$PR_HEAD_SHA" >> $GITHUB_ENV
72
71
echo "IMAGE_NAME=quay.io/trustyai/guardrails-detector-huggingface-runtime-ci" >> $GITHUB_ENV
73
72
echo "BUILTIN_IMAGE_NAME=quay.io/trustyai/guardrails-detector-built-in-ci" >> $GITHUB_ENV
74
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
75
75
- name : Set main-branch environment
76
76
if : env.BUILD_CONTEXT == 'main'
77
- env :
78
- QUAY_RELEASE_REPO : ${{ vars.QUAY_RELEASE_REPO }}
79
77
run : |
80
78
echo "TAG=latest" >> $GITHUB_ENV
81
79
echo "IMAGE_NAME=$QUAY_RELEASE_REPO" >> $GITHUB_ENV
82
80
echo "BUILTIN_IMAGE_NAME=quay.io/trustyai/guardrails-detector-built-in" >> $GITHUB_ENV
83
81
echo "LLM_JUDGE_IMAGE_NAME=quay.io/trustyai/guardrails-detector-llm-judge" >> $GITHUB_ENV
82
+ echo "EXPIRY_LABEL=" >> $GITHUB_ENV
84
83
- name : Set tag environment
85
84
if : env.BUILD_CONTEXT == 'tag'
86
- env :
87
- GITHUB_REF_NAME : ${{ github.ref_name }}
88
- QUAY_RELEASE_REPO : ${{ vars.QUAY_RELEASE_REPO }}
89
85
run : |
90
86
echo "TAG=$GITHUB_REF_NAME" >> $GITHUB_ENV
91
87
echo "IMAGE_NAME=$QUAY_RELEASE_REPO" >> $GITHUB_ENV
92
88
echo "BUILTIN_IMAGE_NAME=quay.io/trustyai/guardrails-detector-built-in" >> $GITHUB_ENV
93
89
echo "LLM_JUDGE_IMAGE_NAME=quay.io/trustyai/guardrails-detector-llm-judge" >> $GITHUB_ENV
90
+ echo "EXPIRY_LABEL=" >> $GITHUB_ENV
94
91
#
95
92
# Run docker commands
96
- - name : Put expiry date on CI-tagged image
97
- if : env.BUILD_CONTEXT == 'ci'
98
- run : |
99
- echo 'LABEL quay.expires-after=7d#' >> detectors/Dockerfile.hf
100
- echo 'LABEL quay.expires-after=7d#' >> detectors/Dockerfile.builtIn
101
- echo 'LABEL quay.expires-after=7d#' >> detectors/Dockerfile.judge
102
93
- name : Build image
103
- run : docker build -t "$IMAGE_NAME:$TAG" -f detectors/Dockerfile.hf detectors
94
+ run : docker build -t "$IMAGE_NAME:$TAG" $EXPIRY_LABEL -f detectors/Dockerfile.hf detectors
104
95
- name : Log in to Quay
105
96
env :
106
97
QUAY_ROBOT_USERNAME : ${{ secrets.QUAY_ROBOT_USERNAME }}
@@ -109,11 +100,11 @@ jobs:
109
100
- name : Push to Quay CI repo
110
101
run : docker push "$IMAGE_NAME:$TAG"
111
102
- name : Build built-in detector image
112
- run : docker build -t "$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
113
104
- name : Push to Quay CI repo
114
105
run : docker push "$BUILTIN_IMAGE_NAME:$TAG"
115
106
- name : Build LLM Judge detector image
116
- run : docker build -t "$LLM_JUDGE_IMAGE_NAME:$TAG" -f detectors/Dockerfile.judge detectors
107
+ run : docker build -t "$LLM_JUDGE_IMAGE_NAME:$TAG" $EXPIRY_LABEL -f detectors/Dockerfile.judge detectors
117
108
- name : Push LLM Judge image to Quay CI repo
118
109
run : docker push "$LLM_JUDGE_IMAGE_NAME:$TAG"
119
110
# Leave comment
@@ -128,18 +119,16 @@ jobs:
128
119
- uses : peter-evans/create-or-update-comment@v4
129
120
if : env.BUILD_CONTEXT == 'ci'
130
121
name : Generate/update success message comment
131
- env :
132
- PR_HEAD_SHA : ${{ github.event.pull_request.head.sha }}
133
122
with :
134
123
comment-id : ${{ steps.fc.outputs.comment-id }}
135
124
issue-number : ${{ github.event.pull_request.number }}
136
125
edit-mode : replace
137
126
body : |
138
127
PR image build completed successfully!
139
128
140
- 📦 [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`
141
- 📦 [PR image](https://quay.io/trustyai/guardrails-detector-built-in-ci?tab=tags): `quay.io/trustyai/guardrails-detector-built-in-ci:$PR_HEAD_SHA`
142
- 📦 [PR image](https://quay.io/trustyai/guardrails-detector-llm-judge-ci?tab=tags): `quay.io/trustyai/guardrails-detector-llm-judge-ci:$PR_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`
143
132
- name : Trivy scan
144
133
uses :
aquasecurity/[email protected]
145
134
with :
0 commit comments