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:
- 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.
- 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?
2
Answers
This is similar to another question.
The answer in the other question suggests using
to check if the PR is a draft, since there might otherwise be some type confusion with booleans in GitHub Actions.
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: