17

I want that my GitHub Action that runs all tests doesn't execute when we push a new tag to the master repository because when we merge new branches we execute this action before, and when we push a tag to create a new release this action executes again.

Right now this action starts with this

name: Build and Test on: push 

As you see this will execute in every push we would make, and I want to change that this action will execute only when we push commits, no tags. My approximate solution would be this but I am not sure

name: Build and Test on: push: branches: - '*' tags-ignore: - '*' 

1 Answer 1

16

That should work, but I'd recommend two improvements.

First, use ** instead of * (the edge case here is a branch/tag named /).

Second, omit the tags-ignore clause. In my testing, Github ignores all tags if you specify branches but not tags or tags-ignore.

name: Build and Test on: push: branches: - '**' 
Sign up to request clarification or add additional context in comments.

2 Comments

Can confirm this works. This is very helpful if your pipeline builds on each commit sha, the tag build would be purely redundant.
Just want to highlight that I ended up getting this error unless I explicitly set --tags-ignore: - '**'. i.e. the tag push was rejected even though my workflow only accepted this push-trigger. on: push: branches: -master

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.