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:
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.
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?
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With