I'm writing a github actions workflow where I take in an array of strings as a global env variable and want to read it in as a part of the matrix strategy.
I get the following error:
Error when evaluating 'strategy' for job '$JOB_NAME'. .github/workflows/deploy.yaml (Line: 53, Col: 18): Error parsing fromJson,.github/workflows/deploy.yaml (Line: 53, Col: 18): Input string '9.0.0' is not a valid number. Path '[0]', line 1, position 6.,.github/workflows/deploy.yaml (Line: 53, Col: 18): Unexpected value ''
This is what my setup currently looks like. I have the job 'prepare-matrix' set up since matrix can't access the env context directly.
env:
VERSIONS: '[9.0.0, 11.0.0]'
jobs:
prepare-matrix:
name: Prepare Matrix Output
runs-on: ubuntu-latest
outputs:
all_versions: ${{ steps.step1.outputs.matrix }}
steps:
- name: Create Matrix Variable
id: step1
run: echo "matrix=${{env.VERSIONS}}" >> $GITHUB_OUTPUT
deploy-gke:
name: Deploy to GKE
runs-on: ubuntu-latest
needs: [prepare-matrix]
strategy:
max-parallel: 2
matrix:
version: ${{ fromJSON(needs.prepare-matrix.outputs.all_versions) }}
steps:
...(several steps to complete job)....
I believe there is some formatting issue wrong somewhere either in env.VERSIONS, or in matrix.version, and I've tried changing parentheses, quotes, and removing the fromJSON(), but nothing seems to resolve the issue.
VERSIONS: '["9.0.0", "11.0.0"]'VERSIONS: '[\"9.0.0\", \"11.0.0\"]'.