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

Tag workflows being triggered when new branch is created

Solved! Go to Solution.

We have seperate workflows for when a new branch is created, and when we create a new tag. Currently whenever a new branch is created in Github, both the branch and the tag workflows are run. I have tried a lot of different iterations of this, but cannot for the life of me get this working. No matter what I try, when a new branch is created the tag workflow is run (as well as the branch, which obviously is fine).

 

Here are the iterations I have tried (all of them run when a new branch is created):

name: tag workflow

on:
  create:
    tags:
name: tag workflow

on:
  push:
    branches-ignore:
      - '*'
    tags:
      - 'v-*'
  create:
    branches-ignore:
      - '*'
    tags:
      - 'v-*'
name: tag workflow

on:
  push:
    branches-ignore:
      - '*'
    tags:
  create:
    branches-ignore:
      - '*'
    tags:
name: tag workflow

on:
  push:
    branches-ignore:
    tags:
  create:
    tags:

To reiterate, I only want this workflow to run when a new tag is created not when a new branch is created.

1 Reply
Highlighted
Solution
GitHub Partner
Message 2 of 2

Re: Tag workflows being triggered when new branch is created

Hi @fahanson ,

 

The yaml syntax is incorrect in your workflow. The ‘create’ event will be triggered when a new branch or a tag created. Tags/branches-ignore are used for push/pull_request not for create event. Please check official doc below for more details:

https://help.github.com/en/actions/reference/events-that-trigger-workflows#create-event-create

https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#onpushpull_requestbr...

If you’d like to only monitor the new tag, you should remove ‘create’ event in yaml file, code sample as below:

on:
  push:
    branches-ignore:
      - '*'
    tags:
      - 'v*'

Thanks.