Skip to content

Commit e93146b

Browse files
authored
Add BoM collect workflow and image publish workflow (opea-project#600)
Signed-off-by: chensuyue <suyue.chen@intel.com>
1 parent a6385bc commit e93146b

File tree

4 files changed

+151
-48
lines changed

4 files changed

+151
-48
lines changed

.github/workflows/_example-workflow.yml

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@ on:
3232
default: false
3333
required: false
3434
type: boolean
35-
publish:
36-
default: false
37-
required: false
38-
type: boolean
39-
publish_tags:
40-
default: "latest"
41-
required: false
42-
type: string
4335
GenAIComps_branch:
4436
default: "main"
4537
required: false
@@ -83,7 +75,7 @@ jobs:
8375
####################################################################################################
8476
# Trivy Scan
8577
####################################################################################################
86-
image-list:
78+
get-image-list:
8779
needs: [build-images]
8880
if: ${{ fromJSON(inputs.scan) && inputs.node == 'gaudi' }}
8981
runs-on: ubuntu-latest
@@ -97,16 +89,16 @@ jobs:
9789
id: scan-matrix
9890
run: |
9991
pip install yq
100-
compose_path=${{ github.workspace }}/.github/workflows/docker/compose/${{ inputs.example }}-compose.yaml
92+
compose_path=${{ github.workspace }}/${{ inputs.example }}/docker/docker_build_compose.yaml
10193
echo "matrix=$(cat ${compose_path} | yq -r '.[]' | jq 'keys' | jq -c '.')" >> $GITHUB_OUTPUT
10294
10395
scan-images:
104-
needs: [image-list, build-images]
96+
needs: [get-image-list, build-images]
10597
if: ${{ fromJSON(inputs.scan) && inputs.node == 'gaudi'}}
10698
runs-on: "docker-build-${{ inputs.node }}"
10799
strategy:
108100
matrix:
109-
image: ${{ fromJSON(needs.image-list.outputs.matrix) }}
101+
image: ${{ fromJSON(needs.get-image-list.outputs.matrix) }}
110102
fail-fast: false
111103
steps:
112104
- name: Pull Image
@@ -118,16 +110,16 @@ jobs:
118110
uses: opea-project/validation/actions/trivy-scan@main
119111
with:
120112
image-ref: ${{ env.OPEA_IMAGE_REPO }}opea/${{ matrix.image }}:${{ inputs.tag }}
121-
output: ${{ inputs.example }}-${{ matrix.image }}-scan.txt
113+
output: ${{ matrix.image }}-scan.txt
122114

123115
- name: Cleanup
124116
if: always()
125117
run: docker rmi -f ${OPEA_IMAGE_REPO}opea/${{ matrix.image }}:${{ inputs.tag }}
126118

127119
- uses: actions/upload-artifact@v4.3.4
128120
with:
129-
name: ${{ inputs.example }}-${{ matrix.image }}-scan
130-
path: ${{ inputs.example }}-${{ matrix.image }}-scan.txt
121+
name: ${{ matrix.image }}-scan
122+
path: ${{ matrix.image }}-scan.txt
131123
overwrite: true
132124

133125
####################################################################################################
@@ -156,22 +148,3 @@ jobs:
156148
hardware: ${{ inputs.node }}
157149
tag: ${{ inputs.tag }}
158150
secrets: inherit
159-
160-
161-
####################################################################################################
162-
# Publish
163-
####################################################################################################
164-
publish:
165-
needs: [image-list, build-images, scan-images, test-example-compose]
166-
if: ${{ fromJSON(inputs.publish) && inputs.node == 'gaudi' }}
167-
strategy:
168-
matrix:
169-
image: ${{ fromJSON(needs.image-list.outputs.matrix) }}
170-
runs-on: "docker-build-gaudi"
171-
steps:
172-
- name: Image Publish
173-
uses: opea-project/validation/actions/image-publish@main
174-
with:
175-
local_image_ref: ${OPEA_IMAGE_REPO}opea/${{ matrix.image }}:${{ inputs.tag }}
176-
image_name: opea/${{ matrix.image }}
177-
publish_tags: ${{ inputs.publish_tags }}

.github/workflows/manual-bom-scan.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Copyright (C) 2024 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Examples docker images BoM scan
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
node:
9+
default: "gaudi"
10+
description: "Hardware to run test"
11+
required: true
12+
type: string
13+
examples:
14+
default: "ChatQnA"
15+
description: 'List of examples to test [AudioQnA,ChatQnA,CodeGen,CodeTrans,DocSum,FaqGen,SearchQnA,Translation]'
16+
required: true
17+
type: string
18+
tag:
19+
default: "latest"
20+
description: "Tag to apply to images"
21+
required: true
22+
type: string
23+
24+
permissions: read-all
25+
jobs:
26+
get-image-list:
27+
runs-on: ubuntu-latest
28+
outputs:
29+
matrix: ${{ steps.scan-matrix.outputs.matrix }}
30+
steps:
31+
- name: Checkout out Repo
32+
uses: actions/checkout@v4
33+
34+
- name: Set Matrix
35+
id: scan-matrix
36+
run: |
37+
pip install yq
38+
examples=($(echo ${{ inputs.examples }} | tr ',' ' '))
39+
image_list=[]
40+
for example in ${examples[@]}
41+
do
42+
images=$(cat ${{ github.workspace }}/${example}/docker/docker_build_compose.yaml | yq -r '.[]' | jq 'keys' | jq -c '.')
43+
image_list=$(echo ${image_list} | jq -s '.[0] + .[1] | unique' - <(echo ${images}))
44+
done
45+
echo "matrix=$(echo ${image_list} | jq -c '.')" >> $GITHUB_OUTPUT
46+
47+
scan-license:
48+
needs: get-image-list
49+
runs-on: "docker-build-${{ inputs.node }}"
50+
strategy:
51+
matrix:
52+
image: ${{ fromJson(needs.get-image-list.outputs.matrix) }}
53+
fail-fast: false
54+
steps:
55+
- name: Pull Image
56+
run: |
57+
docker pull ${OPEA_IMAGE_REPO}opea/${{ matrix.image }}:${{ inputs.tag }}
58+
echo "OPEA_IMAGE_REPO=${OPEA_IMAGE_REPO}" >> $GITHUB_ENV
59+
60+
- name: Scan Container
61+
uses: opea-project/validation/actions/license-scan@main # TODO
62+
with:
63+
image-ref: ${{ env.OPEA_IMAGE_REPO }}opea/${{ matrix.image }}:${{ inputs.tag }}
64+
output: ${{ matrix.image }}-scan.txt
65+
66+
- name: Cleanup
67+
if: always()
68+
run: docker rmi -f ${OPEA_IMAGE_REPO}opea/${{ matrix.image }}:${{ inputs.tag }}
69+
70+
- uses: actions/upload-artifact@v4.3.4
71+
with:
72+
name: ${{ matrix.image }}-scan
73+
path: ${{ matrix.image }}-scan.txt
74+
overwrite: true
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Copyright (C) 2024 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Examples CD workflow on manual event
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
nodes:
9+
default: "gaudi"
10+
description: "Hardware to run test"
11+
required: true
12+
type: string
13+
examples:
14+
default: "ChatQnA"
15+
description: 'List of examples to test [AudioQnA,ChatQnA,CodeGen,CodeTrans,DocSum,FaqGen,SearchQnA,Translation]'
16+
required: true
17+
type: string
18+
tag:
19+
default: "latest"
20+
description: "Tag to apply to images"
21+
required: true
22+
type: string
23+
publish:
24+
default: false
25+
description: 'Publish images to docker hub'
26+
required: false
27+
type: boolean
28+
publish_tags:
29+
default: "latest,v1.0"
30+
description: 'Tag list apply to publish images'
31+
required: false
32+
type: string
33+
34+
permissions: read-all
35+
jobs:
36+
get-image-list:
37+
runs-on: ${{ inputs.node }}
38+
outputs:
39+
matrix: ${{ steps.scan-matrix.outputs.matrix }}
40+
steps:
41+
- name: Checkout out Repo
42+
uses: actions/checkout@v4
43+
44+
- name: Set Matrix
45+
id: scan-matrix
46+
run: |
47+
examples=($(echo ${{ inputs.examples }} | tr ',' ' '))
48+
image_list=[]
49+
for example in ${examples[@]}
50+
do
51+
images=$(cat ${{ github.workspace }}/${example}/docker/docker_build_compose.yaml | yq -r '.[]' | jq 'keys' | jq -c '.')
52+
image_list=$(echo ${image_list} | jq -s '.[0] + .[1] | unique' - <(echo ${images}))
53+
done
54+
echo "matrix=$(echo ${image_list} | jq -c '.')" >> $GITHUB_OUTPUT
55+
56+
publish:
57+
needs: [get-image-list]
58+
strategy:
59+
matrix:
60+
image: ${{ fromJSON(needs.get-image-list.outputs.matrix) }}
61+
runs-on: "docker-build-${{ inputs.node }}"
62+
steps:
63+
- name: Image Publish
64+
uses: opea-project/validation/actions/image-publish@main
65+
with:
66+
local_image_ref: ${OPEA_IMAGE_REPO}opea/${{ matrix.image }}:${{ inputs.tag }}
67+
image_name: opea/${{ matrix.image }}
68+
publish_tags: ${{ inputs.publish_tags }}

.github/workflows/manual-cd-workflow.yml renamed to .github/workflows/manual-example-workflow.yml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,6 @@ on:
4040
description: 'Test examples with k8s'
4141
required: false
4242
type: boolean
43-
publish:
44-
default: false
45-
description: 'Publish images to docker hub'
46-
required: false
47-
type: boolean
48-
publish_tags:
49-
default: "latest,v1.0"
50-
description: 'Tag list apply to publish images'
51-
required: false
52-
type: string
5343
GenAIComps_branch:
5444
default: "main"
5545
description: 'GenAIComps branch for image build'
@@ -67,10 +57,10 @@ jobs:
6757
- name: Create Matrix
6858
id: get-matrix
6959
run: |
70-
examples=($(echo ${{ github.event.inputs.examples }} | tr ',' ' '))
60+
examples=($(echo ${{ inputs.examples }} | tr ',' ' '))
7161
examples_json=$(printf '%s\n' "${examples[@]}" | sort -u | jq -R '.' | jq -sc '.')
7262
echo "examples=$examples_json" >> $GITHUB_OUTPUT
73-
nodes=($(echo ${{ github.event.inputs.nodes }} | tr ',' ' '))
63+
nodes=($(echo ${{ inputs.nodes }} | tr ',' ' '))
7464
nodes_json=$(printf '%s\n' "${nodes[@]}" | sort -u | jq -R '.' | jq -sc '.')
7565
echo "nodes=$nodes_json" >> $GITHUB_OUTPUT
7666
@@ -90,7 +80,5 @@ jobs:
9080
scan: ${{ fromJSON(inputs.scan) }}
9181
test_compose: ${{ fromJSON(inputs.test_compose) }}
9282
test_k8s: ${{ fromJSON(inputs.test_k8s) }}
93-
publish: ${{ fromJSON(inputs.publish) }}
94-
publish_tags: ${{ inputs.publish_tags }}
9583
GenAIComps_branch: ${{ inputs.GenAIComps_branch }}
9684
secrets: inherit

0 commit comments

Comments
 (0)