diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 9dc0c685..5a2b9c78 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -166,8 +166,10 @@ jobs: run: | tags=$(echo "${{ steps.meta.outputs.tags }}" | grep -oE ':([^[:space:]]+)' | sed '/label/d' | sed 's/://g' | tr '\n' ' ') single_tag=$(echo "$tags" | cut -d " " -f 1) + remaining_tags=$(echo "$tags" | cut -d' ' -f2-) echo "tags=$tags" >> $GITHUB_OUTPUT echo "single_tag=$single_tag" >> $GITHUB_OUTPUT + echo "remaining_tags=$remaining_tags" >> $GITHUB_OUTPUT - name: Pull database image if: contains(fromJSON('["aries-endorser-db"]'), matrix.service) @@ -186,12 +188,20 @@ jobs: tags: ${{ steps.extract.outputs.tags }} # labels would have to be added to the image after the S2I build - - name: Apply Labels to Database Image + - name: Apply Labels and tags to Database Image id: apply_labels if: contains(fromJSON('["aries-endorser-db"]'), matrix.service) run: | echo "FROM ${{ steps.build_image.outputs.image }}:${{ steps.extract.outputs.single_tag }}" | docker build -t ${{ steps.build_image.outputs.image }}:${{ steps.extract.outputs.single_tag }} --label ca.bc.gov.digitaltrust.build.source-location=${{ github.repositoryUrl }} --label ca.bc.gov.digitaltrust.build.commit.id=${{ github.sha }} - - + - name: Apply Tags to Docker Image + run: | + remaining_tags="${{ steps.extract.outputs.remaining_tags }}" + image_name="${{ steps.build_image.outputs.image }}" + IFS=' ' read -r -a tags_array <<< "$remaining_tags" + # Loop through the tags and apply each one to the Docker image + for tag in "${tags_array[@]}"; do + docker tag "$image_name:${{ steps.extract.outputs.single_tag }}" "$image_name:$tag" + done - name: Push database image id: push