New environment file issues with Outputs and fromJson
See original GitHub issueDescribe the bug Getting deprecated “set-output” command warning, so I decided to update the notation to use github environment files, but started getting these errors in both self-hosted and GitHub-hosted servers:
Error when evaluating 'strategy' for job 'Test_Second_Job'. .github/workflows/github-actions-demo.yml (Line: 28, Col: 21): Error parsing fromJson,.github/workflows/github-actions-demo.yml (Line: 28, Col: 21): Error reading JToken from JsonReader. Path '', line 0, position 0.,.github/workflows/github-actions-demo.yml (Line: 28, Col: 21): Unexpected type of value '', expected type: Sequence.
I made changes according to the following link: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
I created a very basic version of the workflow yaml file to try and pinpoint the issue as in the below link, but even that is giving the same errors: https://github.com/TheOnlyWei/github_actions_test/blob/env-filetest/.github/workflows/github-actions-demo.yml https://github.com/TheOnlyWei/github_actions_test/actions/runs/3398602911
name: GitHub Actions Demo
on:
pull_request:
branches:
- main
workflow_dispatch:
jobs:
Test_First_Job:
runs-on: windows-2019
steps:
- name: Convert input to JSON for matrix.
id: matrix_json_step
shell: pwsh
run: |
$jsonArrayString = "[`"test1:test2:test3`",`"test4:test5:test6`"]"
echo "JSON_ARRAY=${jsonArrayString}" >> $GITHUB_OUTPUT
outputs:
JSON_ARRAY: ${{ steps.matrix_json_step.outputs.JSON_ARRAY }}
Test_Second_Job:
runs-on: windows-2019
needs: Test_First_Job
strategy:
fail-fast: false
matrix:
JSON_ARRAY: ${{ fromJson(needs.Test_First_Job.outputs.JSON_ARRAY) }}
steps:
- name: Print JSON_ARRAY
shell: pwsh
run: |
Write-Host "JSON_ARRAY VALUE IN SECOND JOB: ${{ matrix.JSON_ARRAY }}"
Anyone know how to fix this error? According to official document, the above should work. The above code worked fine with old “set-output” format.
According to fromJson doc, the above should work? https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson
To Reproduce See above.
Expected behavior Expected behavior is that using the new GitHub environment file should produce no errors like the deprecated “set-output” command, but there is an error.
Runner Version and Platform
Version of your runner? 2.298.2
OS of the machine running the runner? OSX/Windows/Linux/… Windows Server 2016 Datacenter
What’s not working?
See above.
Job Log Output
See above.
Runner and Worker’s Diagnostic Logs
Not applicable.
Issue Analytics
- State:
- Created 10 months ago
- Reactions:5
- Comments:13 (2 by maintainers)
Top GitHub Comments
Same is happening to me, and the issue seems to be specific to fromJson + matrix. My process is:
Error:
Error when evaluating 'strategy' for job 'build_job_name'. .github/workflows/workflow_name.yaml (Line: 118, Col: 15): Error parsing fromJson,.github/workflows/workflow_name.yaml (Line: 118, Col: 15): Error reading JToken from JsonReader. Path '', line 0, position 0.,.github/workflows/deploy_dev.yaml (Line: 118, Col: 15): Unexpected type of value '', expected type: Mapping.
Also I need to add this was working fine before, and it was broken when I came back to work on Monday. I’ve been trying to fix it since without luck.
For any googlers, I had a similar problem in bash because I used double quotes (
"
) instead of single quotes ('
) when creating the output. In my case, I could fix the issue by changinghttps://github.com/hpi-swa-lab/SqueakByExample-english/pull/137/commits/01707f0b56ac9eacc2bb003e6b354174434ceb07