I am building a multiline string of an image to be pushed to multiple registries using the docker build/push action. I use the actions' script.
- uses: actions/github-script@v6
id: set-images
with:
script: |
let imageList = '';
let Base = '${{ env.REPOSITORY }}'+'/'+'${{ env.GCR_PROJECT }}'+'/'+'${{ inputs.image_name }}'
if (${{ inputs.image_build }}) {
imageList += (Base+':${{ inputs.image_tag }}\n');
}
if (${{ inputs.image_tag_stable }}) {
imageList += (Base+':stable\n');
}
.
.
.
return imageList.trim()
and the build:
- name: build and push images
uses: docker/build-push-action@v3
with:
push: true
context: ${{ inputs.context }}
build-args: ${{ inputs.build_args }}
tags: ${{ steps.set-images.outputs.result }}
However the last one fails due to the \n being literally interpreted by the tags input
invalid tag "gcr.io/my-gcr-project/my-image:my-tag\\ngcr.io/my-gcr-project/my-tag:latest\\n": invalid reference format
Any way around this?