fix(templatecenter): use redo template ID in generated request and va… #553
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 Check | |
| on: | |
| push: | |
| branches: [master] | |
| paths: | |
| - 'CubeAPI/**' | |
| - 'CubeMaster/**' | |
| - 'Cubelet/**' | |
| - 'CubeShim/**' | |
| - 'agent/**' | |
| - 'network-agent/**' | |
| - 'docker/Dockerfile.builder' | |
| - '.github/workflows/build-builder-image.yml' | |
| - '.github/workflows/build-check.yml' | |
| - 'Makefile' | |
| pull_request: | |
| paths: | |
| - 'CubeAPI/**' | |
| - 'CubeMaster/**' | |
| - 'Cubelet/**' | |
| - 'CubeShim/**' | |
| - 'agent/**' | |
| - 'network-agent/**' | |
| - 'docker/Dockerfile.builder' | |
| - '.github/workflows/build-builder-image.yml' | |
| - '.github/workflows/build-check.yml' | |
| - 'Makefile' | |
| workflow_dispatch: | |
| concurrency: | |
| group: build-check-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| packages: read | |
| env: | |
| BUILDER_IMAGE_REMOTE: ghcr.io/tencentcloud/cubesandbox-builder:ubuntu2004 | |
| BUILDER_IMAGE_LOCAL: cube-sandbox-builder:ci | |
| jobs: | |
| build: | |
| name: Build ${{ matrix.component }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - component: CubeAPI | |
| make_target: cubeapi | |
| expected_bins: | | |
| _output/bin/cube-api | |
| - component: CubeMaster | |
| make_target: cubemaster | |
| expected_bins: | | |
| _output/bin/cubemaster | |
| _output/bin/cubemastercli | |
| - component: Cubelet | |
| make_target: cubelet | |
| expected_bins: | | |
| _output/bin/cubelet | |
| _output/bin/cubecli | |
| - component: agent | |
| make_target: agent | |
| expected_bins: | | |
| _output/bin/cube-agent | |
| - component: CubeShim | |
| make_target: shim | |
| expected_bins: | | |
| _output/bin/containerd-shim-cube-rs | |
| _output/bin/cube-runtime | |
| - component: network-agent | |
| make_target: network-agent | |
| expected_bins: | | |
| _output/bin/network-agent | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Detect builder changes | |
| id: builder_changes | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then | |
| base_ref="${{ github.event.pull_request.base.sha }}" | |
| head_ref="${{ github.event.pull_request.head.sha }}" | |
| else | |
| base_ref="${{ github.event.before }}" | |
| head_ref="${GITHUB_SHA}" | |
| fi | |
| if [[ -z "${base_ref}" || "${base_ref}" == "0000000000000000000000000000000000000000" ]]; then | |
| changed_files="$(git diff-tree --no-commit-id --name-only -r "${head_ref}")" | |
| else | |
| changed_files="$(git diff --name-only "${base_ref}" "${head_ref}")" | |
| fi | |
| printf 'Changed files:\n%s\n' "${changed_files}" | |
| builder_inputs_changed="false" | |
| while IFS= read -r file; do | |
| case "${file}" in | |
| docker/Dockerfile.builder|.github/workflows/build-builder-image.yml) | |
| builder_inputs_changed="true" | |
| break | |
| ;; | |
| esac | |
| done <<< "${changed_files}" | |
| echo "changed=${builder_inputs_changed}" >> "${GITHUB_OUTPUT}" | |
| - name: Log in to GitHub Container Registry | |
| id: ghcr_login | |
| if: steps.builder_changes.outputs.changed != 'true' | |
| continue-on-error: true | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Warn about GHCR login failure | |
| if: steps.ghcr_login.outcome == 'failure' | |
| shell: bash | |
| run: echo "::warning::GHCR login failed - will attempt pull as anonymous or build locally" | |
| - name: Resolve builder image | |
| id: builder_image | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| build_local_builder_image() { | |
| docker build \ | |
| -t "${BUILDER_IMAGE_LOCAL}" \ | |
| -f docker/Dockerfile.builder \ | |
| --build-arg GITHUB_ACTIONS=true \ | |
| --build-arg RUSTUP_DIST_SERVER=https://static.rust-lang.org \ | |
| --build-arg RUSTUP_UPDATE_ROOT=https://static.rust-lang.org/rustup \ | |
| . | |
| } | |
| image="${BUILDER_IMAGE_REMOTE}" | |
| if [[ "${{ steps.builder_changes.outputs.changed }}" == "true" ]]; then | |
| echo "Builder inputs changed, building local builder image..." | |
| build_local_builder_image | |
| image="${BUILDER_IMAGE_LOCAL}" | |
| elif docker pull "${BUILDER_IMAGE_REMOTE}"; then | |
| echo "Using published builder image ${BUILDER_IMAGE_REMOTE}" | |
| else | |
| echo "Failed to pull ${BUILDER_IMAGE_REMOTE}, building local fallback image..." | |
| build_local_builder_image | |
| image="${BUILDER_IMAGE_LOCAL}" | |
| fi | |
| echo "image=${image}" >> "${GITHUB_OUTPUT}" | |
| - name: Build ${{ matrix.component }} | |
| shell: bash | |
| env: | |
| MAKE_TARGET: ${{ matrix.make_target }} | |
| EXPECTED_BINS: ${{ matrix.expected_bins }} | |
| run: | | |
| set -euo pipefail | |
| echo "Component: ${{ matrix.component }}" | |
| echo "Builder image: ${{ steps.builder_image.outputs.image }}" | |
| make "${MAKE_TARGET}" \ | |
| BUILDER_IMAGE="${{ steps.builder_image.outputs.image }}" | |
| while IFS= read -r binary; do | |
| [[ -n "${binary}" ]] || continue | |
| if ! test -x "${binary}"; then | |
| echo "::error::Expected binary not found or not executable: ${binary}" | |
| exit 1 | |
| fi | |
| done <<< "${EXPECTED_BINS}" |