I am converting a GitHub Actions file from a version that contains multiple mostly copy-paste Docker build steps using environment variables, to a version that uses a one-dimensional matrix with multiple values and a single Docker build action.
Problem is I can't get the matrix expanded from environment variables.
I am aware that one ENV can't contain another ENV, and a solution is to set in one build step and use in another.
I am aware that the matrix entry does not expand environment variables, and an option is use JSON text in one step and fromJSON() in the matrix step.
From this action file, the error is: line 1: {: command not found
It looks like the shell is interpreting the {
as a new command and ignoring the \
line continuation in the previous line.
Code snippets:
run: |
JSON=[ { \
"name": "NxMeta-LSIO Latest Develop", \
"enable": ${{ (github.ref == 'refs/heads/develop') }}, \
"push": ${{ (github.event_name != 'pull_request') }}, \
"context": ./NxMeta-LSIO, \
"tags": [ ptr727/nxmeta-lsio:develop, ptr727/nxmeta-lsio:develop-latest, ptr727/nxmeta-lsio:develop-${{ env.NXMETA_LATEST_VERSION }} ], \
"args": [ DOWNLOAD_VERSION=${{ env.NXMETA_LATEST_VERSION }}, DOWNLOAD_URL=${{ env.NXMETA_LATEST_URL }} ] \
}, \
{ \
"name": "NxMeta-LSIO Stable Develop", \
"enable": ${{ (github.ref == 'refs/heads/develop') }}, \
"push": ${{ (github.event_name != 'pull_request') }}, \
"context": ./NxMeta-LSIO, \
"tags": [ ptr727/nxmeta-lsio:develop-stable, ptr727/nxmeta-lsio:develop-${{ env.NXMETA_STABLE_VERSION }} ], \
"args": [ DOWNLOAD_VERSION=${{ env.NXMETA_STABLE_VERSION }}, DOWNLOAD_URL=${{ env.NXMETA_STABLE_URL }} ] \
}, \
...
echo "::set-output name=matrix::${JSON//'%'/'%25'}"
matrix:
containers: ${{fromJson(needs.setmatrix.outputs.matrix)}}
Any ideas?