create-or-update-comment
create-or-update-comment copied to clipboard
Support reading body from a file
Ran into an issue where the body stored in the environment variable was throwing an error saying Error: Argument list too long (similar to https://github.com/peter-evans/create-or-update-comment/issues/96).
Added support for file and fileEncoding arguments which can be passed in order to allow accessing the body directly from files, bypassing the need to store the body as a variable and escaping it. This also removes the restriction of the body content being too long to be supported by sh.
PTAL @peter-evans
@peter-evans this would really help if this get merged/reviewed. Thnx!
@umanghome can you maybe sync your branch again? Then we can make use of the fork for now until this is merged (or not) Thnx!
@umanghome Thank you for contributing this. Apologies for not looking at it sooner.
This issue comes up occasionally for a few of the actions I maintain. I was really trying to avoid adding this feature to read input from files for a few reasons:
- I wanted to keep the action interfaces simple
- I didn't want to open up the actions to a wave of new feature requests around file IO, such as templating.
- This is really a runner environment limitation that we are having to work around. It just feels broken/wrong to have to do this.
However, I don't see any sign that this will be fixed at an environment level, so I'm considering merging this.
Thnx for the reply. Just a note that if you use the file based method and have multiline comments you don't require this
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
To make multiline work.
But i agree that with your reasoning but i sadly also don't see that the env limitation with be fixed anytime soon.
@umanghome, (and anyone else following this issue), do you need the input fileEncoding to specify something other than utf8? I'm wondering if you just added that as a "just in case someone finds this useful" feature.
If nobody needs it then I will omit it until there is a need.
@peter-evans fileEncoding is definitely a "just in case someone finds this useful" feature.
I can remove it from the changes in this branch if you'd like.
@umanghome Got it. Thanks for confirming.
I'm going to merge this to a feature branch so I can make some tweaks and add a test. Then I'll merge it into main with your contributions.
Released as v2.1.0 / v2. Note that I decided to change the input name from file to body-file to make it a little more specific.
Thank you @umanghome