I've written action in Github actions. In push events, a variable is provided by GitHub that starts with github
.
Json preview of the variable is:
{
"event_name": "push",
"event": {
"after": "aaaaaaaaaaaaaaaaa",
"base_ref": null,
"before": "bbbbbbbbbbbbbbbb",
"commits": [
{
"author": {
"username": "myUser"
},
"id": "bbbbbbbbbbbbbbbb",
"message": "myCommitMessage",
"url": "https://github.com/myUser/myRepo/commit/bbbbbbbbbbbbbbbb"
}
],
"compare": "https://github.com/myUser/myRepo/compare/"
}
}
I want to write a script that iterates on github.event.commits
and creates something like this:
commits=${{github.event.commits}}
length=${#commits[@]}
for (( i = 0; i < length; i++ )); do
commit=${{github.event.commits[i]}}
echo url=${{commit.url}}
echo sha=${{commit.id}}
echo actor=${{commit.author.username}}
echo message=${{commit.message}}
done
But the id
doesn't work. I got this error:
Unrecognized named-value: 'i'. Located at position 22 within expression: github.event.commits[i]