Samuel Sanchez
Samuel Sanchez

Reputation: 151

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:
      - '*'

Upvotes: 15

Views: 4972

Answers (1)

pschale
pschale

Reputation: 261

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:
      - '**'

Upvotes: 16

Related Questions