abinoda / label-when-approved-action

GitHub Action that labels approved pull requests
MIT License
191 stars 131 forks source link

jq: error (at <stdin>:4): Cannot index string with string "state" #107

Open moonwalkerpoday opened 8 months ago

moonwalkerpoday commented 8 months ago

Same issue as this one. https://github.com/abinoda/label-when-approved-action/issues/63

Oddly enough, I was able to get the value without any problems when I verified jq in another workflow.

image

However, I get a jq error when I run label-when-approved-action@master.

image

It also works fine in some repositories. Does this result depend on the repository settings?

moonwalkerpoday commented 4 months ago

I was investigating the values parsed by jq, and upon finding a 403 error message, I resolved the issue by changing the settings 🎉

Run body=$(curl -sSL -H "Authorization: token ***" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/<repo>/pulls/<pr number>/reviews?per_page=100")
{
  "message": "Resource not accessible by integration",
  "documentation_url": "https://docs.github.com/rest/pulls/reviews#list-reviews-for-a-pull-request",
  "status": "403"
}

Settings > Actions > General > Workflow permissions

image