Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 3
Message 1 of 4

Don't run actions on draft pull requests

Solved! Go to Solution.

I am trying to set up my workflow so it doesn't run when opening/synching/reopening pull requests that are marked as draft.

 

I have found that I can use

if: github.event.pull_request.draft == false

on my job, but it will still run for a few seconds, and "fail", leaving a red X on every commit on the PR until it is marked ready for reveiw.

 

I could maybe add a dummy-job that has

if: github.event.pull_request.draft == true

on it, and just echo something, but it will still run for a few seconds though.

 

My test-workfow so far looks like this:

 

name: Deploy test

on: 
  pull_request:
    branches: [master]
    types: [synchronize, opened, reopened, ready_for_review]

jobs:
  build:
    runs-on: ubuntu-latest
    if: github.event.pull_request.draft == false
    timeout-minutes: 10

    steps:
    - uses: actions/checkout@v1
    - name: Run all the stuff to set up my site and run tests
      run: set_up_site

  draft-build:
    runs-on: ubuntu-latest
    if: github.event.pull_request.draft == true
    timeout-minutes: 1

    steps:
    - name: Run a one-line script
      run: echo Draft PR, you are good.

 

Will those seconds be added up and billed? Is there another or better way of getting around this?

3 Replies
Highlighted
Solution
Pilot Lvl 2
Message 2 of 4

Re: Don't run actions on draft pull requests

jobs.<id>.if is broken currently, that's why you get "fail" instead of "skip" status.

Highlighted
Copilot Lvl 3
Message 3 of 4

Re: Don't run actions on draft pull requests

Ah, okay. So if I just leave it as-is and they fix the issue it won't be a problem?

Highlighted
Pilot Lvl 2
Message 4 of 4

Re: Don't run actions on draft pull requests

Yeah, if you don't mind extra notifications. I'm not touching mine waiting for a fix - beauty of betas :]