Check PR body length in GitHub Actions workflow

Viewed 17

I am trying to create a workflow with pull_request trigger to check if the PR body content have more than x characters.

I can verify if the body is empty as shown below:

name: pr-description
on:
  pull_request:

jobs:
  check-body:
    runs-on: default
    steps:
      - name: Check body
        if: ${{ github.event.pull_request.body == '' }}
        run: echo 'Please provide a description'; exit 1;

I've looked for a function on Expression section on GitHub docs but I couldn't find anything related to what I need, like stringLength().

Tried to access the content as string inside the if clause but had no success: if: ${{ fromJson(github.event.pull_request.body).length < 15 }}

Any ideas?

0 Answers
Related