create-or-update-comment icon indicating copy to clipboard operation
create-or-update-comment copied to clipboard

Support reading body from a file

Open umanghome opened this issue 3 years ago • 1 comments
trafficstars

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.

umanghome avatar Jun 01 '22 18:06 umanghome

PTAL @peter-evans

daulet avatar Aug 10 '22 20:08 daulet

@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!

AtzeDeVries avatar Oct 17 '22 12:10 AtzeDeVries

@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:

  1. I wanted to keep the action interfaces simple
  2. I didn't want to open up the actions to a wave of new feature requests around file IO, such as templating.
  3. 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.

peter-evans avatar Oct 17 '22 13:10 peter-evans

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.

AtzeDeVries avatar Oct 18 '22 07:10 AtzeDeVries

@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 avatar Oct 21 '22 07:10 peter-evans

@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 avatar Oct 21 '22 07:10 umanghome

@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.

peter-evans avatar Oct 24 '22 05:10 peter-evans

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

peter-evans avatar Oct 24 '22 06:10 peter-evans