image-actions icon indicating copy to clipboard operation
image-actions copied to clipboard

Limit markdown to 65535?

Open rakkarage opened this issue 2 years ago • 4 comments

The markdown output can be over 65535 characters if convert many images, which causes error with peter-evans/create-pull-request@v3 since github body can only be 65535. Fixed with truncate action but perhaps there should/could be a limit built in? I guess it is not limited to just being used for github pull requests tho so maybe not. Thanks.

rakkarage avatar Mar 12 '22 17:03 rakkarage

Similar to #107 ?

lfgcampos avatar Aug 27 '22 09:08 lfgcampos

create-pull-request@v6 fixed this: changelog

If the pull request body is truncated due to exceeding the maximum length, the action will now suffix the body with the message "...[Pull request body truncated]" to indicate that the body has been truncated.

I haven't tested myself though but maybe just updating the version used by this action will fix it =)

lfgcampos avatar Feb 05 '24 17:02 lfgcampos

@lfgcampos Unfortunately v6 doesn't fix it.

Here's a v4 run, here's a v6 run.

Here's the error that was previously shown:

An error occurred trying to start process '/home/runner/runners/2.313.0/externals/node16/bin/node' with working directory '/home/runner/work/blog-personal/blog-personal'. Argument list too long

Here's the new error:

An error occurred trying to start process '/home/runner/runners/2.313.0/externals/node20/bin/node' with working directory '/home/runner/work/blog-personal/blog-personal'. Argument list too long

JakeSteam avatar Feb 18 '24 00:02 JakeSteam

Limiting the variable length within the .yml file is an acceptable workaround. I was only running a one-off job so just used an empty body & echo'd the markdown so that the PR could be successfully created, a proper solution probably includes a cut step or something.

My hacky fix let it successfully create a PR that changed 1,516 files(!) and saved 186MB(!!!). The details can be seen in the "Echo markdown" step of the job.

Here's the full workaround .yml:

# https://github.com/calibreapp/image-actions?tab=readme-ov-file#compress-on-demand-or-on-schedule
name: Compress Images
on:
  workflow_dispatch:
  
jobs:
  build:
    name: calibreapp/image-actions
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v3
      - name: Compress Images
        id: calibre
        uses: calibreapp/image-actions@main
        with:
          githubToken: "${{ secrets.GITHUB_TOKEN }}"
          compressOnly: true
      - name: Echo markdown
        run: echo ${{ steps.calibre.outputs.markdown }}
      - name: Create New Pull Request If Needed
        if: steps.calibre.outputs.markdown != ''
        uses: peter-evans/create-pull-request@v6
        with:
          title: Compressed Images
          branch-suffix: timestamp
          commit-message: Compressed Images
          body: ""

JakeSteam avatar Feb 18 '24 00:02 JakeSteam