diff --git a/.github/workflows/_gmc-workflow.yml b/.github/workflows/_gmc-workflow.yml new file mode 100644 index 0000000000..5faf2f8a26 --- /dev/null +++ b/.github/workflows/_gmc-workflow.yml @@ -0,0 +1,130 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +name: Build and upgrade GMC system on call and manual + +on: + workflow_dispatch: + inputs: + tag: + default: "latest" + required: false + type: string + workflow_call: + inputs: + tag: + default: "latest" + required: false + type: string + pull_request: + branches: [main] + types: [opened, reopened, ready_for_review, synchronize] # added `ready_for_review` since draft is skipped + paths: + - .github/workflows/_gmc-workflow.yml + +jobs: +#################################################################################################### +# Image Build and Scan +#################################################################################################### + image-build: + strategy: + matrix: + platform: [docker-build-xeon] + runs-on: ${{ matrix.platform }} + steps: + - name: Checkout GenAIInfra repository + uses: actions/checkout@v4 + with: + repository: opea-project/GenAIInfra + #ref: ${{ inputs.tag }} + path: GenAIInfra + + - name: Set variables + id: set_variables + run: | + echo "DOCKER_REGISTRY=${OPEA_IMAGE_REPO}opea" >> $GITHUB_ENV + echo "IMAGE_REPO=${OPEA_IMAGE_REPO}" >> $GITHUB_OUTPUT + # echo "VERSION=${{ inputs.tag }}" >> $GITHUB_ENV + # echo "VERSION=${{ inputs.tag }}" >> $GITHUB_OUTPUT + echo "VERSION=latest" >> $GITHUB_ENV + echo "VERSION=latest" >> $GITHUB_OUTPUT + + - name: Build image and push + run: | + cd ${{github.workspace}}/GenAIInfra/microservices-connector + make docker.build + make docker.push + + - name: Scan gmcmanager + uses: opea-project/validation/actions/trivy-scan@main + with: + image-ref: ${{ env.DOCKER_REGISTRY }}/gmcmanager:${{ env.VERSION }} + output: gmcmanager-scan.txt + + - uses: actions/upload-artifact@v4.3.4 + with: + name: gmcmanager-scan + path: gmcmanager-scan.txt + overwrite: true + + - name: Scan gmcrouter + uses: opea-project/validation/actions/trivy-scan@main + with: + image-ref: ${{ env.DOCKER_REGISTRY }}/gmcrouter:${{ env.VERSION }} + output: gmcrouter-scan.txt + + - uses: actions/upload-artifact@v4.3.4 + with: + name: gmcrouter-scan + path: gmcrouter-scan.txt + overwrite: true + + - name: Clean up images + if: always() + run: | + docker rmi ${{ env.DOCKER_REGISTRY }}/gmcrouter:${{ env.VERSION }} + docker rmi ${{ env.DOCKER_REGISTRY }}/gmcmanager:${{ env.VERSION }} + + - name: Clean up GenAIInfra source codes + run: | + rm -rf ${{github.workspace}}/GenAIInfra + +#################################################################################################### +# GMC Install +#################################################################################################### + gmc-install: + strategy: + matrix: + platform: [k8s-xeon] + needs: image-build + runs-on: ${{ matrix.platform }} + steps: + - name: Checkout GenAIInfra repository + uses: actions/checkout@v4 + with: + repository: opea-project/GenAIInfra + #ref: ${{ inputs.tag }} + path: GenAIInfra + + - name: Set variables + run: | + echo "SYSTEM_NAMESPACE=opea-system" >> $GITHUB_ENV + #echo "VERSION=${{ inputs.tag }}" >> $GITHUB_ENV + echo "VERSION=latest" >> $GITHUB_ENV + echo "SET_VERSION=true" >> $GITHUB_ENV + + - name: Cleanup existing GMC + run: | + cd GenAIInfra + .github/workflows/scripts/e2e/gmc_install.sh cleanup_gmc + cd .. + + - name: Install GMC + run: | + cd GenAIInfra + .github/workflows/scripts/e2e/gmc_install.sh install_gmc + cd .. + + - name: Clean up GenAIInfra source codes + run: | + rm -rf ${{github.workspace}}/GenAIInfra