From bdd403dbf900a47a3c2ccb924ba3cecf0f10b1c0 Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Fri, 4 Oct 2024 17:08:04 +0100 Subject: [PATCH] workflow: Fix CAA build artifact upload With the actions/upload-artifact@v4 artifacts that are uploaded need unique names. Previously the tag.txt was uploading in all the matrix steps resulting in duplications, so separate it out as a pre-job which follows the same logic as before and then merge the arch specific files back together in the manifest step. Signed-off-by: stevenhorsman --- .../caa_build_and_push_per_arch.yaml | 48 +++++++++++++++++-- src/cloud-api-adaptor/hack/build.sh | 6 +-- 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/.github/workflows/caa_build_and_push_per_arch.yaml b/.github/workflows/caa_build_and_push_per_arch.yaml index 44f66070e2..8e4cfe634a 100644 --- a/.github/workflows/caa_build_and_push_per_arch.yaml +++ b/.github/workflows/caa_build_and_push_per_arch.yaml @@ -51,8 +51,37 @@ defaults: working-directory: src/cloud-api-adaptor jobs: + upload_tags: + runs-on: ubuntu-latest + steps: + - name: Checkout the code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: "${{ inputs.git_ref }}" + + - name: Create tags.txt + run: | + # Matches expected logic in ./hack/build.sh + commit=$(git rev-parse HEAD) + dev_tags=${{ inputs.dev_tags }} + release_tags=${{ inputs.release_tags }} + echo "dev_tags=${dev_tags:-latest,dev-${commit}}" > tags.txt + echo "release_tags=${release_tags:-${commit}}" >> tags.txt + # debug + cat tags.txt + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: image-tags + retention-days: 1 + path: | + src/cloud-api-adaptor/tags.txt + build_push_job: name: build and push + needs: [upload_tags] runs-on: ubuntu-latest strategy: fail-fast: false @@ -87,13 +116,16 @@ jobs: uses: actions/setup-go@v4 with: go-version: ${{ env.GO_VERSION }} + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 + - name: Install build dependencies if: ${{ startsWith(matrix.type, 'dev-') }} run: | sudo apt-get update -y sudo apt-get install -y libvirt-dev + - name: Login to quay Container Registry if: ${{ startsWith(inputs.registry, 'quay.io') }} uses: docker/login-action@v3 @@ -139,12 +171,11 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v4 with: - name: image-artifacts + name: image-artifacts-${{matrix.type}} retention-days: 1 path: | - src/cloud-api-adaptor/tags.txt src/cloud-api-adaptor/tags-architectures-* - + manifest_job: name: generate images manifest runs-on: ubuntu-latest @@ -156,11 +187,18 @@ jobs: fetch-depth: 0 ref: "${{ inputs.git_ref }}" + - name: tags.txt + uses: actions/download-artifact@v4 + with: + name: image-tags + path: src/cloud-api-adaptor/tags.txt + - name: Download release commits file uses: actions/download-artifact@v4 with: - name: image-artifacts - path: src/cloud-api-adaptor + pattern: my-artifact-* + merge-multiple: true + path: src/cloud-api-adaptor/tags-architectures- - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 diff --git a/src/cloud-api-adaptor/hack/build.sh b/src/cloud-api-adaptor/hack/build.sh index 29db58de3d..df7065d82e 100755 --- a/src/cloud-api-adaptor/hack/build.sh +++ b/src/cloud-api-adaptor/hack/build.sh @@ -22,7 +22,7 @@ release_tags=${RELEASE_TAGS:-"${commit}"} supported_arches=${ARCHES:-"linux/amd64"} -tags_file="${script_dir}/../tags.txt" +# tags_file="${script_dir}/../tags.txt" arch_file_prefix="${script_dir}/../tags-architectures-" arch_prefix="linux/" @@ -84,8 +84,8 @@ function build_caa_payload_arch_specific() { arch=${supported_arches#"$arch_prefix"} - echo "dev_tags="$dev_tags > "$tags_file" - echo "release_tags="$release_tags >> "$tags_file" + # echo "dev_tags="$dev_tags > "$tags_file" + # echo "release_tags="$release_tags >> "$tags_file" echo "arch="$arch >> "$arch_file_prefix$arch" local tag_string