Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I not execute a GitHub Action when I push a new tag?

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:
      - '*'
like image 910
Samuel Sanchez Avatar asked Dec 18 '25 17:12

Samuel Sanchez


1 Answers

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:
      - '**'
like image 105
pschale Avatar answered Dec 21 '25 12:12

pschale



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!