Skip to content

Commit

Permalink
workflow: Fix CAA build artifact upload
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
stevenhorsman committed Oct 7, 2024
1 parent 6ea1fce commit bdd403d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 8 deletions.
48 changes: 43 additions & 5 deletions .github/workflows/caa_build_and_push_per_arch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/cloud-api-adaptor/hack/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/"

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bdd403d

Please sign in to comment.