I have to pass a json that is read from a json file, to a github action I created, this action takes the text at the moment and simply prints it as seen in the js code above.
The problem is that I can’t pass the json as a variable.
Can you give me a hand?
Json:
[
{
"repository": "https://github.com/zed-industries/zed",
"commit": "fb3ef0d140156511e4880d689a01ae60f5b89fcf"
},
{
"repository": "https://github.com/gdamore/tree-sitter-d",
"commit": "750dde90ed9cdbd82493bc28478d8ab1976b0e9f"
},
{
"repository": "https://github.com/CodeEditApp/CodeEdit",
"commit": "051a83737415c71b9d7d0eb9dda751d5232940e6"
},
{
"repository": "https://github.com/zed-industries/zeds",
"commit": "051a83737415c71b9d7d0eb9dda751d5232940e6"
}
]
Js code of the private repo that is called:
import { getInput, setFailed } from "@actions/core";
const list = getInput("list");
console.log("typeof", typeof list);
console.log("list", list);
console.log("length", list.length);
Github action:
on:
workflow_dispatch
name: Check commit
jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Read repository
id: read_repo
run: echo "branchs=$(echo ${cat repository.json})" >> $GITHUB_OUTPUT
- name: Check repository
uses: nameRepoPrivate/check_commit@main
with:
list: "${{ steps.read_repo.outputs.branchs }}"
Github action result:
typeof string
list
length 0
other way
on:
workflow_dispatch
name: Check commit
jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Read repository
id: read_repo
run: |
echo "branchs=$(cat repository.json)" >> $GITHUB_ENV
echo "::set-output name=branchs::$(cat repository.json)"
- name: Check repository
uses: nameRepoPrivate/check_commit@main
with:
list: ${{ steps.read_repo.outputs.branchs }}
Github action result:
Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
.....
Error: Unable to process file command 'env' successfully.
Error: Invalid format ' {'
...