title: Multiline GitHub Action Matrix operation with environment variables
body: <p>I am converting a GitHub Actions file from a <a href="https://github.com/ptr727/NxWitness/blob/main/.github/workflows/BuildPublishPipeline.yml" rel="nofollow noreferrer">version</a> that contains multiple mostly copy-paste Docker build steps using environment variables, to a <a href="https://github.com/ptr727/NxWitness/blob/develop/.github/workflows/BuildPublishPipeline.yml" rel="nofollow noreferrer">version</a> that uses a one-dimensional matrix with multiple values and a single Docker build action.</p>
  <p>Problem is I can't get the matrix expanded from environment variables.</p>
  <p>I am <a href="https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files" rel="nofollow noreferrer">aware</a> that one ENV can't contain another ENV, and a solution is to set in one build step and use in another.</p>
  <p>I am <a href="https://stackoverflow.com/questions/61919141/read-json-file-in-github-actions">aware</a> 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.</p>
  <p>From <a href="https://github.com/ptr727/NxWitness/blob/develop/.github/workflows/BuildPublishPipeline.yml" rel="nofollow noreferrer">this</a> action file, the <a href="https://github.com/ptr727/NxWitness/runs/7227086573?check_suite_focus=true" rel="nofollow noreferrer">error</a> is: <code>line 1: {: command not found</code></p>
  <p>It looks like the shell is interpreting the <code>{</code> as a new command and ignoring the <code>\</code> line continuation in the previous line.</p>
  <p>Code snippets:</p>
  <pre class="lang-yaml prettyprint-override"><code>      run: |
          JSON=[ { \
                    &quot;name&quot;: &quot;NxMeta-LSIO Latest Develop&quot;, \
                    &quot;enable&quot;: ${{ (github.ref == 'refs/heads/develop') }}, \
                    &quot;push&quot;: ${{ (github.event_name != 'pull_request') }}, \
                    &quot;context&quot;: ./NxMeta-LSIO, \
                    &quot;tags&quot;: [ ptr727/nxmeta-lsio:develop, ptr727/nxmeta-lsio:develop-latest, ptr727/nxmeta-lsio:develop-${{ env.NXMETA_LATEST_VERSION }} ], \
                    &quot;args&quot;: [ DOWNLOAD_VERSION=${{ env.NXMETA_LATEST_VERSION }}, DOWNLOAD_URL=${{ env.NXMETA_LATEST_URL }} ] \
                  }, \
                  { \
                    &quot;name&quot;: &quot;NxMeta-LSIO Stable Develop&quot;, \
                    &quot;enable&quot;: ${{ (github.ref == 'refs/heads/develop') }}, \
                    &quot;push&quot;: ${{ (github.event_name != 'pull_request') }}, \
                    &quot;context&quot;: ./NxMeta-LSIO, \
                    &quot;tags&quot;: [ ptr727/nxmeta-lsio:develop-stable, ptr727/nxmeta-lsio:develop-${{ env.NXMETA_STABLE_VERSION }} ], \
                    &quot;args&quot;: [ DOWNLOAD_VERSION=${{ env.NXMETA_STABLE_VERSION }}, DOWNLOAD_URL=${{ env.NXMETA_STABLE_URL }} ] \
                  }, \
  ...
        echo &quot;::set-output name=matrix::${JSON//'%'/'%25'}&quot;
  </code></pre>
  <pre class="lang-yaml prettyprint-override"><code>matrix:
    containers: ${{fromJson(needs.setmatrix.outputs.matrix)}}
  </code></pre>
  <p>Any ideas?</p>