From 903cbbe1bfaa2be49c9bd85cbb61ca72b8413250 Mon Sep 17 00:00:00 2001 From: Philipp Belitz Date: Fri, 25 Oct 2024 14:59:26 +0200 Subject: [PATCH] fixup! wip: ci-settings + build --- .github/workflows/101_build.yml | 75 +++++++++++++++------------------ 1 file changed, 35 insertions(+), 40 deletions(-) diff --git a/.github/workflows/101_build.yml b/.github/workflows/101_build.yml index 9fa17ea56..dad34b676 100644 --- a/.github/workflows/101_build.yml +++ b/.github/workflows/101_build.yml @@ -45,17 +45,17 @@ jobs: if: inputs.run_build != 'none' permissions: {} outputs: - chart_version: ${{ steps.get_context.outputs.CHART_VERSION }} - original_registry: ${{ steps.get_context.outputs.ORIGINAL_REGISTRY }} - original_repo: ${{ steps.get_context.outputs.ORIGINAL_REPO }} - original_image: ${{ steps.get_context.outputs.ORIGINAL_IMAGE }} - original_tag: ${{ steps.get_context.outputs.ORIGINAL_TAG }} - build_registry: ${{ steps.get_context.outputs.BUILD_REGISTRY }} - build_repo: ${{ steps.get_context.outputs.BUILD_REPO }} - build_tag: ${{ steps.show_context.outputs.BUILD_TAG }} - build_image: ${{ steps.show_context.outputs.BUILD_IMAGE }} + chart_version: ${{ steps.output_context.outputs.CHART_VERSION }} + original_registry: ${{ steps.output_context.outputs.ORIGINAL_REGISTRY }} + original_repo: ${{ steps.output_context.outputs.ORIGINAL_REPO }} + original_image: ${{ steps.output_context.outputs.ORIGINAL_IMAGE }} + original_tag: ${{ steps.output_context.outputs.ORIGINAL_TAG }} + build_registry: ${{ steps.output_context.outputs.BUILD_REGISTRY }} + build_repo: ${{ steps.output_context.outputs.BUILD_REPO }} + build_tag: ${{ steps.output_context.outputs.BUILD_TAG }} + build_image: ${{ steps.output_context.outputs.BUILD_IMAGE }} build_labels: ${{ steps.meta.outputs.labels }} - ref_tags: ${{ steps.show_context.outputs.REF_TAGS }} + ref_tags: ${{ steps.output_context.outputs.REF_TAGS }} steps: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -74,17 +74,10 @@ jobs: uses: mikefarah/yq@47f4f8c7939f887e851b35f14def6741b8f5396e # v4.31.2 with: cmd: yq '.kubernetes.deployment.image.repository' charts/connaisseur/values.yaml - - name: Get context - id: get_context + - name: Get repo name + id: get_repo_name run: | GHREF=${{ github.ref }} - echo "github.ref is: ${GHREF}" - CHART_VERSION=${{ steps.get_chart_version.outputs.result }} - CONFIGURED_IMAGE_REPO=${{ steps.get_original_image_repository.outputs.result }} - ORIGINAL_REGISTRY=$(echo "${CONFIGURED_IMAGE_REPO}" | cut -d "/" -f 1) - ORIGINAL_REPO=$(echo "${CONFIGURED_IMAGE_REPO}" | cut -d "/" -f 2- | cut -d ":" -f 1) - ORIGINAL_TAG=v${{ steps.get_app_version.outputs.result }} - BUILD_REGISTRY="ghcr.io" BUILD_REPO=${{ github.repository }} if [[ "${GHREF}" != "refs/heads/master" && "${GHREF}" != "refs/tags/v"* && @@ -92,20 +85,13 @@ jobs: ]]; then BUILD_REPO="${BUILD_REPO}-test" fi - - echo CHART_VERSION=${CHART_VERSION} >> ${GITHUB_OUTPUT} - echo ORIGINAL_REGISTRY=${ORIGINAL_REGISTRY} >> ${GITHUB_OUTPUT} - echo ORIGINAL_REPO=${ORIGINAL_REPO} >> ${GITHUB_OUTPUT} - echo ORIGINAL_TAG=${ORIGINAL_TAG} >> ${GITHUB_OUTPUT} - echo ORIGINAL_IMAGE=${CONFIGURED_IMAGE_REPO}:${ORIGINAL_TAG} >> ${GITHUB_OUTPUT} - echo BUILD_REGISTRY=${BUILD_REGISTRY} >> ${GITHUB_OUTPUT} echo BUILD_REPO=${BUILD_REPO} >> ${GITHUB_OUTPUT} shell: bash - name: Generate metadata id: meta uses: docker/metadata-action@507c2f2dc502c992ad446e3d7a5dfbe311567a96 # v4.3.0 with: - images: ${{ steps.get_context.outputs.BUILD_REGISTRY }}/${{ steps.get_context.outputs.BUILD_REPO }} + images: ghcr.io/${{ steps.get_repo_name.outputs.BUILD_REPO }} flavor: | latest=true tags: | @@ -114,27 +100,35 @@ jobs: type=ref,event=tag type=ref,event=pr type=sha - - name: Show context - id: show_context + - name: Output context + id: output_context run: | - PREFIX=$(echo "${{ steps.get_context.outputs.BUILD_REGISTRY }}/${{ steps.get_context.outputs.BUILD_REPO }}:" | sed 's%/%\/%g') + CHART_VERSION=${{ steps.get_chart_version.outputs.result }} + CONFIGURED_IMAGE_REPO=${{ steps.get_original_image_repository.outputs.result }} + ORIGINAL_REGISTRY=$(echo "${CONFIGURED_IMAGE_REPO}" | cut -d "/" -f 1) + ORIGINAL_REPO=$(echo "${CONFIGURED_IMAGE_REPO}" | cut -d "/" -f 2- | cut -d ":" -f 1) + ORIGINAL_TAG=v${{ steps.get_app_version.outputs.result }} + BUILD_REGISTRY="ghcr.io" + BUILD_REPO=${{ steps.get_repo_name.outputs.BUILD_REPO }} + PREFIX=$(echo "${BUILD_REGISTRY}/${BUILD_REPO}:" | sed 's%/%\/%g') TAGS="${{ steps.meta.outputs.tags }}" REF_TAGS="${TAGS//${PREFIX}/}" BUILD_IMAGE=$(echo "${TAGS}" | tail -2 | head -1) BUILD_TAG="${BUILD_IMAGE//${PREFIX}/}" [[ ${BUILD_TAG} == "sha-"* ]] || exit 1 # check as parsing of the BUILD_TAG maybe fragile and dependent on docker/metadata-action priorities REF_TAGS="${REF_TAGS//${BUILD_TAG}/}" + + + echo CHART_VERSION=${CHART_VERSION} >> ${GITHUB_OUTPUT} + echo ORIGINAL_REGISTRY=${ORIGINAL_REGISTRY} >> ${GITHUB_OUTPUT} + echo ORIGINAL_REPO=${ORIGINAL_REPO} >> ${GITHUB_OUTPUT} + echo ORIGINAL_TAG=${ORIGINAL_TAG} >> ${GITHUB_OUTPUT} + echo ORIGINAL_IMAGE=${CONFIGURED_IMAGE_REPO}:${ORIGINAL_TAG} >> ${GITHUB_OUTPUT} + echo BUILD_REGISTRY=${BUILD_REGISTRY} >> ${GITHUB_OUTPUT} + echo BUILD_REPO=${BUILD_REPO} >> ${GITHUB_OUTPUT} echo BUILD_TAG=${BUILD_TAG} >> ${GITHUB_OUTPUT} echo BUILD_IMAGE=${BUILD_IMAGE} >> ${GITHUB_OUTPUT} echo REF_TAGS=${REF_TAGS} >> ${GITHUB_OUTPUT} - echo "# :clipboard: Context" >> ${GITHUB_STEP_SUMMARY} - echo "" >> ${GITHUB_STEP_SUMMARY} - echo "" >> ${GITHUB_STEP_SUMMARY} - echo "" >> ${GITHUB_STEP_SUMMARY} - echo "" >> ${GITHUB_STEP_SUMMARY} - echo "" >> ${GITHUB_STEP_SUMMARY} - echo "" >> ${GITHUB_STEP_SUMMARY} - echo "
Build ContextValue
Helm chart version${{ steps.get_context.outputs.CHART_VERSION }}
Original image${{ steps.get_context.outputs.ORIGINAL_IMAGE }}
Build image${BUILD_IMAGE}
All build images${{ steps.meta.outputs.tags }}
" >> ${GITHUB_STEP_SUMMARY} shell: bash build: @@ -178,9 +172,10 @@ jobs: run: | echo "# :building_construction: Build Information" >> ${GITHUB_STEP_SUMMARY} echo "" >> ${GITHUB_STEP_SUMMARY} - echo "" >> ${GITHUB_STEP_SUMMARY} + echo "" >> ${GITHUB_STEP_SUMMARY} + echo "" >> ${GITHUB_STEP_SUMMARY} echo "" >> ${GITHUB_STEP_SUMMARY} - echo "" >> ${GITHUB_STEP_SUMMARY} + echo "" >> ${GITHUB_STEP_SUMMARY} echo "" >> ${GITHUB_STEP_SUMMARY} echo "
Build artifactsValue
Helm chart version${{ needs.context.outputs.chart_version }}
Original image${{ needs.context.outputs.original_image }}
Workflow image${{ needs.context.outputs.build_registry }}/${{ needs.context.outputs.build_repo }}:${{ needs.context.outputs.build_tag }}
All reference tags$(echo ${{ steps.tags.outputs.tags }} | tr ',' '\n')
All images$(echo ${{ steps.tags.outputs.tags }} | tr ',' '\n')
Digest${{ steps.build.outputs.digest }}
" >> ${GITHUB_STEP_SUMMARY} echo "" >> ${GITHUB_STEP_SUMMARY}