|
| 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 |
0 commit comments