Workflow is running twice when creating a new branch

I have a workflow that is supposed to run whenever

  • I create a new branch OR
  • I push some commits to a branch that is not the “master”-branch.

What I’ve come up so far is this:

on:
  push:
    branches-ignore:
      - master
    tags-ignore:
      - '**'
  create:
    type:
      - branch

It works for both cases I’ve listed above, BUT…
Whenever I create a new branch (without any other change to it), the workflow is triggered twice (at the same time):

  • one for event “create”
  • one for event “push”

Question:
How can I make it run only once when I create a new branch?

Thanks in advance for any help!

Creating a new branch usually involves creating it locally and then pushing it, that’s why the push event triggers in addition to create. So the solution is: Drop the create event from the workflow triggers. :slightly_smiling_face:

The create event is useful if you want a workflow that runs only for new branches.

2 Likes

@airtower-luna Thank you! Works like a charm :slight_smile:

1 Like