# GitHub: How to rerun a pipeline if PR changes from draft -\> ready or vice versa

**URL:** <https://forum.buildkite.community/t/github-how-to-rerun-a-pipeline-if-pr-changes-from-draft-ready-or-vice-versa/2519>\
**Category:** Pipelines\
**Created:** [January 20, 2023, 9:02pm UTC](https://forum.buildkite.community/t/github-how-to-rerun-a-pipeline-if-pr-changes-from-draft-ready-or-vice-versa/2519 "2023-01-20T21:02:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![john.soo](https://avatars.discourse-cdn.com/v4/letter/j/7ba0ec/32.png) [@john.soo](https://forum.buildkite.community/u/john.soo)\
**Post date:** [January 20, 2023, 9:02pm UTC](https://forum.buildkite.community/t/github-how-to-rerun-a-pipeline-if-pr-changes-from-draft-ready-or-vice-versa/2519/1 "2023-01-20T21:02:37Z")

</div>

We have a step like this:

```auto
steps:
  - block: "Build draft PR"
    blocked_state: "failed"
    if: "build.pull_request.draft"

```

Which would be lovely to unblock if the associated PR is moved out of Draft. Do you know of a good way to do this?

---

<div class="post-metadata">

**Author:** ![benmc](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/benmc/32/1159_2.png) [@benmc](https://forum.buildkite.community/u/benmc)\
**Post date:** [January 22, 2023, 10:34pm UTC](https://forum.buildkite.community/t/github-how-to-rerun-a-pipeline-if-pr-changes-from-draft-ready-or-vice-versa/2519/2 "2023-01-22T22:34:45Z")

</div>

Hey @john.soo!

You should be able to do this in the Pipeline settings, as seen below.

 ![Screenshot 2023-01-23 at 9.33.03 am](https://us1.discourse-cdn.com/flex016/uploads/buildkite1/original/2X/b/bd8317f20eca17afb12fa44181142377c6fa764e.png)

AFAIK, there isn’t a way to do the opposite; create a build when a PR changes from ready to review to “draft”.

Cheers,

Ben

---

<div class="post-metadata">

**Author:** ![john.soo](https://avatars.discourse-cdn.com/v4/letter/j/7ba0ec/32.png) [@john.soo](https://forum.buildkite.community/u/john.soo)\
**Post date:** [January 23, 2023, 4:17pm UTC](https://forum.buildkite.community/t/github-how-to-rerun-a-pipeline-if-pr-changes-from-draft-ready-or-vice-versa/2519/3 "2023-01-23T16:17:59Z")

</div>

Hey @benmc, thank you! We do have that option enabled. However rebuilds do not happen. I think because of this?

> [@john.soo](#):
>
> `blocked_state: "failed"`

According to the [docs](https://buildkite.com/docs/pipelines/block-step#block-step-attributes):

> When the `blocked_state` of a block step is set to `failed`, the step that triggered it will be stuck in the `running` state until it is manually unblocked.

But using `passed` gives too many false positives and `running` creates too much clutter. What we really want is to allow `pending` as a `blocked_state`.

---

<div class="post-metadata">

**Author:** ![karen.sawrey](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/karen.sawrey/32/1188_2.png) [@karen.sawrey](https://forum.buildkite.community/u/karen.sawrey)\
**Post date:** [January 23, 2023, 6:55pm UTC](https://forum.buildkite.community/t/github-how-to-rerun-a-pipeline-if-pr-changes-from-draft-ready-or-vice-versa/2519/4 "2023-01-23T18:55:38Z")

</div>

Hello, @john.soo! Thank you for your feedback. Unfortunately, `passed`, `failed`, and `running` are the only 3 values that are currently available for the `blocked_state` attribute.

Best!

---

<div class="post-metadata">

**Author:** ![john.soo](https://avatars.discourse-cdn.com/v4/letter/j/7ba0ec/32.png) [@john.soo](https://forum.buildkite.community/u/john.soo)\
**Post date:** [January 23, 2023, 8:07pm UTC](https://forum.buildkite.community/t/github-how-to-rerun-a-pipeline-if-pr-changes-from-draft-ready-or-vice-versa/2519/5 "2023-01-23T20:07:33Z")

</div>

Hi @karen.sawrey do you know how I can get builds to run when the PR changes out of draft?

I tried using `blocked_state: "passed"` which did nothing. Here are our github settings:

 ![Screen Shot 2023-01-23 at 12.04.34 PM](https://us1.discourse-cdn.com/flex016/uploads/buildkite1/original/2X/a/a07fa0252652c764daefa45f1e77c279290d66bf.png)

But a build is not triggered when a pull request becomes ready. What am I missing?

---

<div class="post-metadata">

**Author:** ![karen.sawrey](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/karen.sawrey/32/1188_2.png) [@karen.sawrey](https://forum.buildkite.community/u/karen.sawrey)\
**Post date:** [January 26, 2023, 5:19pm UTC](https://forum.buildkite.community/t/github-how-to-rerun-a-pipeline-if-pr-changes-from-draft-ready-or-vice-versa/2519/6 "2023-01-26T17:19:40Z")

</div>

Hi, @john.soo! With a block step in your yml, even with the “passed” value for the `blocked_state` attribute, you’ll still need someone to unblock it manually for the build to proceed.

And to be able to get your builds to automatically rerun when a PR’s state changes from “draft” to “ready for review,” you need to disable “Skip pull request builds for existing commits” in your pipeline settings:

 ![disable](https://us1.discourse-cdn.com/flex016/uploads/buildkite1/original/2X/4/4380910de0de1abdd8b10c04001a53532c78fbdd.jpeg)

As for the vice versa action - to get the build to rerun when a PR’s state changes to “draft” - it is unfortunately not supported.

Cheers!

---

<div class="post-metadata">

**Author:** ![john.soo](https://avatars.discourse-cdn.com/v4/letter/j/7ba0ec/32.png) [@john.soo](https://forum.buildkite.community/u/john.soo)\
**Post date:** [January 26, 2023, 7:37pm UTC](https://forum.buildkite.community/t/github-how-to-rerun-a-pipeline-if-pr-changes-from-draft-ready-or-vice-versa/2519/7 "2023-01-26T19:37:42Z")

</div>

Thank you! I am looking into this. We lean pretty heavily on skipping builds for existing commits. I think what would work best for us would be to make the `block_state` of the block somehow “not run”. I suppose if we could build for existing commits, this could work, but these features do seem mutually exclusive.

---

<div class="post-metadata">

**Author:** ![paula](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/paula/32/954_2.png) [@paula](https://forum.buildkite.community/u/paula)\
**Post date:** [August 29, 2023, 5:39am UTC](https://forum.buildkite.community/t/github-how-to-rerun-a-pipeline-if-pr-changes-from-draft-ready-or-vice-versa/2519/8 "2023-08-29T05:39:29Z")

</div>


