Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github Actions: Running a workflow on non-draft PRs

I have workflow file that I want it to run on non-draft PRs and on every new commit to the PR.

So far, I have tried two ways:

  1. Using if statement
name: Test

on:
  pull_request:
    branches:
      - master

jobs:
  test:
    if: github.event.pull_request.draft == false
    runs-on: ubuntu-latest

This does not trigger workflow when PR converted to ready for review.

  1. Using types statement
name: Test

on:
  pull_request:
    branches:
      - master
    types:
      - ready_for_review

jobs:
  test:
    runs-on: ubuntu-latest

This does not trigger workflow when a new commit pushed to PR.

How can I add a condition so that my workflow runs on non-draft PRs and also all new commits?

like image 400
Harun Sasmaz Avatar asked Jun 14 '26 10:06

Harun Sasmaz


1 Answers

In your first code block you leave the types as the default (opened, synchronize & reopened). In the second code block you only use the ready_for_review type.

You can just combine the two:

name: Test

on:
  pull_request:
    types:
      - opened
      - synchronize
      - reopened
      - ready_for_review

jobs:
  test:
    if: github.event.pull_request.draft == false
    # You could have ths version too - note the  single quotes:
    # if: '! github.event.pull_request.draft'
    name: Check PR is not a Draft
    runs-on: ubuntu-latest
    steps:
      - run: |
          echo "Non-draft Pull request change detected"
like image 186
Greg Avatar answered Jun 17 '26 15:06

Greg