Only run actions on non draft pull request

Viewed 2622

I have set Github actions to be skipped when a draft pull request has been created however it is not trigger when the pull request is ready for review. Is there any way to run the action when I draft PR is changed from draft to ready for review?

pull_request:
types: ['opened', 'edited', 'reopened', 'synchronize', 'ready_for_review']

jobs:
 build:
    if: github.event.pull_request.draft == 'false'
    runs-on: ubuntu-latest
1 Answers

pull_request.draft is a boolean, but you're treating it as a string, so the types in your comparison don't match.

According to the docs, the operands are coerced to numbers in this case: the left-hand side (boolean) becomes 1 if true and 0 if false; the right-hand side (string) becomes NaN, so your if statement will never evaluate to true.

To fix, use

    if: ! github.event.pull_request.draft
Related