ryanvade/enforce-pr-description-length-action

Can this reference the PR template?

Opened this issue · 2 comments

As @opotowsky and I were just lamenting, your wonderful GH Action turns out to be inflexible for our repo because we have a lengthy checklist in our PR template. So, any time someone changed the text in that template (which happens regularly), they would need to know to update the "minLength" field in your Action.

Is it POSSIBLE to find the text of the PR template in this Action, and pull the number of characters from it?

  1. If so, could we add that as a feature to this repo?
  2. If you'd rather NOT, could you point me in the right direction, so I could make a fork of your Plugin for our little, bespoke desires?

Sorry, I've never looked at GH Actions plugins before, but based on this page, I'm trying to decide if we could find the PR template in TypeScript in a similar way to your getPullRequestDescription() method, but using something like:

github.workspace + "/.github/pull_request_template.md"

Then I'd need to be able to:

  1. Check if the file exists.
  2. Read it's contents
  3. Return the length of its contents.

It might be doable?

@john-science I had a work around for this;

    - name: Set Length
      id: get_length
      run: echo ::set-output name=template_length::$(curl <url_to_ pull_request_template.md> | wc -m)

    - name: Enforce Pull Request Description Length
      uses: ryanvade/enforce-pr-description-length-action@v1
      with:
        minLength: ${{steps.get_length.outputs.template_length}}

but it's not working perfectly because the string body of the PR, in the json, counts spaces as multiple characters. you will need to add some fudge factor to template_length