AlexSim93 / pull-request-analytics-action

Provides informative reports on team and developer metrics, based on data from pull requests and code reviews
MIT License
110 stars 10 forks source link

Can't export json #51

Closed josiahcoad closed 1 week ago

josiahcoad commented 2 weeks ago

Is your feature request related to a problem? Please describe. Yes, I am trying to export the json (to send to a webhook) and it seems that the string is not properly escaped.

Describe the solution you'd like I'd like the json string to be properly escaped so that I can send it in the webook

Describe alternatives you've considered my current action step after the analytics action contains:

curl -X POST -H "Content-Type: application/json" -d '${{ steps.analytics.outputs.JSON_COLLECTION }}' $WEBHOOK_URL

But one of my PR's has a "'" in it so I think that is causing issue.

Additional context error: unexpected EOF while looking for matching ``'

AlexSim93 commented 2 weeks ago

Hi! I'll check you case. Do you think "'" has been used in a PR's title?

josiahcoad commented 2 weeks ago

But one of my PR's has a "'" in it so I think that is causing issue.

@AlexSim93

P.S. Thanks for making this. It's awesome!

AlexSim93 commented 1 week ago

I tested the action's behavior when a ' character is used in the title. This does not affect the action's performance, and the error occurs at subsequent steps where the action has no further influence. I did some research, and as I understand, one approach is to convert the JSON into a file and work with it afterward. Alternatively, other escaping methods can be used. I will consider generating a file, but when it comes to the collection type, there isn't anything I can change here.

josiahcoad commented 1 week ago

Finally figured it out! You have to assign it to a variable (thanks to this guy).

          DATA: ${{ steps.analytics.outputs.JSON_COLLECTION }}
        run: |
          echo "$DATA" > collection.json
          curl -X POST -H "Content-Type: application/json" -d @collection.json $WEBHOOK_URL

Note that just writing it to a file via echo '${{ steps.analytics.outputs.JSON_COLLECTION }}' > collection.json doesn't work for the same reason.

josiahcoad commented 1 week ago

-