Merge pull request #2137 from milvus-io/optimize-build-yml #3569
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and deploy to preview | |
| on: | |
| repository_dispatch: | |
| types: [dev-deploy] | |
| push: | |
| branches: | |
| - preview | |
| workflow_dispatch: | |
| env: | |
| NODE_OPTIONS: '--max_old_space_size=8192' | |
| jobs: | |
| build: | |
| runs-on: 'ubuntu-latest' | |
| outputs: | |
| docker-image-tag: ${{ steps.generate-tag-name.outputs.docker_tag }} | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| steps: | |
| - name: Free up disk space (comprehensive) | |
| run: | | |
| sudo rm -rf /usr/share/dotnet || true | |
| df -h | |
| - uses: azure/docker-login@v1 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME}} | |
| password: ${{ secrets.DOCKER_PWD}} | |
| - uses: actions/checkout@v3 | |
| with: | |
| ref: 'preview' | |
| fetch-depth: 1 | |
| - name: Verify Nginx configuration | |
| uses: addnab/docker-run-action@v3 | |
| with: | |
| image: zilliz/zilliz-web-runner | |
| options: -v ${{ github.workspace }}/conf/conf.d/client.conf:/etc/nginx/conf.d/client.conf | |
| run: | | |
| if nginx -t -c /etc/nginx/nginx.conf; then | |
| echo "Nginx configuration is valid." | |
| else | |
| echo "Nginx configuration is invalid." | |
| exit 1 | |
| fi | |
| if: always() | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v2 | |
| with: | |
| node-version: '22' | |
| - name: update submodules from preview branch | |
| run: | | |
| git submodule init | |
| git submodule set-branch --branch preview -- src/docs | |
| git submodule update --remote | |
| - name: Check disk space after submodule update | |
| run: | | |
| echo "=== Disk Space Information ===" | |
| df -h | |
| echo "" | |
| echo "=== Disk Usage Summary ===" | |
| df -h --total | grep total | |
| echo "" | |
| echo "=== Available Space on Root Filesystem ===" | |
| df -h / | awk 'NR==2{printf "Total: %s, Used: %s, Available: %s, Usage: %s\n", $2, $3, $4, $5}' | |
| - name: Clean up unnecessary version folders | |
| run: | | |
| # Remove old version folders from /docs/localization/ | |
| rm -rf src/docs/localization/v2.0.x | |
| rm -rf src/docs/localization/v2.1.x | |
| # Remove old version folders from /docs/ | |
| rm -rf src/docs/v0.x | |
| rm -rf src/docs/v1.1.1 | |
| rm -rf src/docs/v2.0.x | |
| rm -rf src/docs/v2.1.x | |
| - name: Generate docker image tag name | |
| id: generate-tag-name | |
| run: | | |
| export tag=${{ github.sha }}-$GITHUB_RUN_NUMBER | |
| echo $tag | |
| echo "docker_tag=$tag" >> $GITHUB_OUTPUT | |
| - name: Building Milvus site and push to docker hub | |
| id: build-image | |
| uses: nick-invision/retry@v2 | |
| with: | |
| timeout_minutes: 60 | |
| max_attempts: 2 | |
| retry_on: error | |
| command: | | |
| docker build "$GITHUB_WORKSPACE/" -f "Preview.Dockerfile" \ | |
| --build-arg MSERVICE_URL=${{ secrets.MSERVICE_URL }} \ | |
| --build-arg CMS_BASE_URL=${{ secrets.CMS_BASE_URL }} \ | |
| --build-arg REPO_STATICS_KEY=${{ secrets.REPO_STATICS_KEY }} \ | |
| --build-arg INKEEP_API_KEY=${{ secrets.INKEEP_API_KEY_DEV }} \ | |
| --build-arg IS_PREVIEW=${{ secrets.PREVIEW_SITE }} \ | |
| -t milvusdb/milvus-io-dev:${{ steps.generate-tag-name.outputs.docker_tag }} | |
| docker push milvusdb/milvus-io-dev:${{ steps.generate-tag-name.outputs.docker_tag }} | |
| # env: | |
| # GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES: true | |
| # CI: true | |
| deploy: | |
| runs-on: amazon-linux-2 | |
| needs: build | |
| steps: | |
| - name: Deploy to cluster | |
| run: | | |
| echo ${{ secrets.kubeconfig }} > config64 | |
| base64 -d config64 > kubeconfig | |
| kubectl set image deployment/milvus-io-dev milvus-io-dev=milvusdb/milvus-io-dev:${{ needs.build.outputs.docker-image-tag }} -n ued --kubeconfig=kubeconfig |