Skip to content

Commit 9b4c803

Browse files
daisy-ycguodmsuehir
authored andcommitted
Add gmc build, scan and deploy workflow (opea-project#611)
Signed-off-by: Yingchun Guo <yingchun.guo@intel.com> Signed-off-by: dmsuehir <dina.s.jones@intel.com>
1 parent 55e0be3 commit 9b4c803

File tree

2 files changed

+164
-0
lines changed

2 files changed

+164
-0
lines changed

.github/workflows/_gmc-workflow.yml

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# Copyright (C) 2024 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Build and deploy GMC system on call and manual
5+
6+
on:
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
default: "latest"
11+
required: true
12+
type: string
13+
description: "Tag to apply to images"
14+
node:
15+
default: "xeon"
16+
required: true
17+
type: string
18+
description: "Hardware to run test"
19+
deploy:
20+
default: true
21+
required: true
22+
type: boolean
23+
description: 'Whether to deploy gmc'
24+
workflow_call:
25+
inputs:
26+
tag:
27+
default: "latest"
28+
required: true
29+
type: string
30+
description: "Tag to apply to images"
31+
node:
32+
default: "xeon"
33+
required: true
34+
type: string
35+
description: "Hardware to run test"
36+
deploy:
37+
default: true
38+
required: true
39+
type: boolean
40+
description: 'Whether to deploy gmc'
41+
42+
jobs:
43+
####################################################################################################
44+
# Image Build and Scan
45+
####################################################################################################
46+
image-build:
47+
runs-on: "docker-build-${{ inputs.node }}"
48+
steps:
49+
- name: Checkout GenAIInfra repository
50+
uses: actions/checkout@v4
51+
with:
52+
repository: opea-project/GenAIInfra
53+
ref: ${{ inputs.tag }}
54+
path: GenAIInfra
55+
56+
- name: Set variables
57+
id: set_variables
58+
run: |
59+
echo "DOCKER_REGISTRY=${OPEA_IMAGE_REPO}opea" >> $GITHUB_ENV
60+
echo "IMAGE_REPO=${OPEA_IMAGE_REPO}" >> $GITHUB_OUTPUT
61+
echo "VERSION=${{ inputs.tag }}" >> $GITHUB_ENV
62+
echo "VERSION=${{ inputs.tag }}" >> $GITHUB_OUTPUT
63+
64+
- name: Build image and push
65+
run: |
66+
cd ${{github.workspace}}/GenAIInfra/microservices-connector
67+
make docker.build
68+
make docker.push
69+
70+
- name: Scan gmcmanager
71+
if: ${{ inputs.node == 'gaudi' }}
72+
uses: opea-project/validation/actions/trivy-scan@main
73+
with:
74+
image-ref: ${{ env.DOCKER_REGISTRY }}/gmcmanager:${{ env.VERSION }}
75+
output: gmcmanager-scan.txt
76+
77+
- name: Upload gmcmanager scan result
78+
if: ${{ inputs.node == 'gaudi' }}
79+
uses: actions/upload-artifact@v4.3.4
80+
with:
81+
name: gmcmanager-scan
82+
path: gmcmanager-scan.txt
83+
overwrite: true
84+
85+
- name: Scan gmcrouter
86+
if: ${{ inputs.node == 'gaudi' }}
87+
uses: opea-project/validation/actions/trivy-scan@main
88+
with:
89+
image-ref: ${{ env.DOCKER_REGISTRY }}/gmcrouter:${{ env.VERSION }}
90+
output: gmcrouter-scan.txt
91+
92+
- name: Upload gmcrouter scan result
93+
if: ${{ inputs.node == 'gaudi' }}
94+
uses: actions/upload-artifact@v4.3.4
95+
with:
96+
name: gmcrouter-scan
97+
path: gmcrouter-scan.txt
98+
overwrite: true
99+
100+
- name: Clean up images
101+
if: always()
102+
run: |
103+
docker rmi ${{ env.DOCKER_REGISTRY }}/gmcrouter:${{ env.VERSION }}
104+
docker rmi ${{ env.DOCKER_REGISTRY }}/gmcmanager:${{ env.VERSION }}
105+
106+
- name: Clean up GenAIInfra source codes
107+
if: always()
108+
run: |
109+
rm -rf ${{github.workspace}}/GenAIInfra
110+
111+
####################################################################################################
112+
# GMC Install
113+
####################################################################################################
114+
gmc-install:
115+
needs: image-build
116+
if: ${{ fromJSON(inputs.deploy) }}
117+
runs-on: "k8s-${{ inputs.node }}"
118+
steps:
119+
- name: Checkout GenAIInfra repository
120+
uses: actions/checkout@v4
121+
with:
122+
repository: opea-project/GenAIInfra
123+
ref: ${{ inputs.tag }}
124+
path: GenAIInfra
125+
126+
- name: Set variables
127+
run: |
128+
echo "SYSTEM_NAMESPACE=opea-system" >> $GITHUB_ENV
129+
echo "VERSION=${{ inputs.tag }}" >> $GITHUB_ENV
130+
echo "SET_VERSION=true" >> $GITHUB_ENV # to change the tag of microservice images
131+
132+
- name: Cleanup existing GMC
133+
run: |
134+
cd GenAIInfra
135+
.github/workflows/scripts/e2e/gmc_install.sh cleanup_gmc
136+
cd ..
137+
138+
- name: Install GMC
139+
run: |
140+
cd GenAIInfra
141+
.github/workflows/scripts/e2e/gmc_install.sh install_gmc
142+
cd ..
143+
144+
- name: Clean up GenAIInfra source codes
145+
if: always()
146+
run: |
147+
rm -rf ${{github.workspace}}/GenAIInfra

.github/workflows/manual-example-workflow.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ on:
2020
description: "Tag to apply to images"
2121
required: true
2222
type: string
23+
deploy_gmc:
24+
default: false
25+
description: 'Whether to deploy gmc'
26+
required: true
27+
type: boolean
2328
build:
2429
default: true
2530
description: 'Build test required images for Examples'
@@ -69,6 +74,18 @@ jobs:
6974
nodes_json=$(printf '%s\n' "${nodes[@]}" | sort -u | jq -R '.' | jq -sc '.')
7075
echo "nodes=$nodes_json" >> $GITHUB_OUTPUT
7176
77+
build-deploy-gmc:
78+
strategy:
79+
matrix:
80+
node: ${{ fromJson(needs.get-test-matrix.outputs.nodes) }}
81+
fail-fast: false
82+
uses: ./.github/workflows/_gmc-workflow.yml
83+
with:
84+
node: ${{ matrix.node }}
85+
tag: ${{ inputs.tag }}
86+
deploy: ${{ fromJSON(inputs.deploy_gmc) }}
87+
secrets: inherit
88+
7289
run-examples:
7390
needs: [get-test-matrix]
7491
strategy:

0 commit comments

Comments
 (0)