Don't run on tag creation?

It seems, that on: [ push ] get’s triggered, whenever you make changes and also, whenever a tag/release is being created. Is there a way to prevent this? I don’t see a need to process a commit, that has already been processed.

If you want to run on pushes but ignore all tags you’d need something like:

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

The branches , branches-ignore , tags , and tags-ignore keywords accept glob patterns that use the * and ** wildcard characters to match more than one branch or tag name. For more information, see the “Filter pattern cheat sheet.”

2 Likes

Ty, I’ll try that. Seems to do, what I’m looking for.

EDIT:

Works well.

@SoftCreatR, @kingthorin,

According to the introduction in the docs:

If you define only tags or only branches, the workflow won’t run for events affecting the undefined Git ref.

If you do not want the push event is triggered when pushing/creating tags, you can only set branch filters (branches or branches-ignore) for the push event in your workflow.

on:
  push:
    branches:
      - 'some branch-filters-patterns'

OR

on:
  push:
    branches-ignore:
      - 'some branch-filters-patterns'

@kingthorin,
If you want to run on pushes but ignore all tags you’d need something like:

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

This configuration will cause the workflow to never be triggered. This is equivalent to disabling the workflow, and this workflow will become meaningless. If so, why don’t you directly delete the workflow file?
The following configurations will cause the same result too.

  • Only set tag filters (tags) with the negative pattern (’!**’).
    on:
      push:
        tags:
          - '!**'
    
  • Only set branch filters (branches) with the negative pattern (’!**’).
    on:
      push:
        branches:
          - '!**'
    
  • Only set branch filters ( branches-ignore) with the positive pattern (’**’).
    on:
      push:
        branches-ignore:
          - '**'
    
1 Like

Good to know. I’ll update the Workflow accordingly.

Fair enough: Any branch, ignore all tags.

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

Although confusingly and contrary to the bit @brightran quoted, https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet states:

'**' `` Matches all branch and tag names. This is the default behavior when you don’t use a branches or tags filter

Which to me implies that if you don’t specify branches then all branches are included… Right? If you don’t include a branch filter then you’re only specifying a tag filter or not specifying a filter at all.

1 Like

@kingthorin, @SoftCreatR,

’**’: Matches all branch and tag names. This is the default behavior when you don’t use a branches or tags filter.

This description includes 3 main situations below:
(Due to the reason I mentioned above, not consider using this pattern for tags-ignore and branches-ignore.)

  1. Only set tag filters ( tags ) with the negative pattern (’**’). The workflow is only triggered when you push tags. Pushing commits to branches can’t trigger the workflow.

    on:
      push:
        tags:
          - '**'
    
  2. Only set branch filters ( branches ) with the negative pattern (’**’). The workflow is only triggered when you push commits to branches. Pushing tags can’t trigger the workflow.

    on:
      push:
        branches:
          - '**'
    
  3. Not set any tag filters and branch filters. The workflow will be triggered by both pushing commits to branches and pushing tags.

    on:
      push:
    

    This configuration is equivalent to:

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

Situation 1 and 2 correspond to the description “Matches all branch and tag names”.
Situation 3 corresponds to the description “This is the default behavior when you don’t use a branches or tags filter”.

Okay, becoming clearer. Should the pattern in 1 and 2 be ‘!**’ (bang double asterisk)? Or, is the word ‘negative’ misplaced? (Or is there something else subtle I’m missing?)

2 Likes

Regarding situation 3, should the wording be slightly changed to make it clearer?

“This is the default behavior when you don’t use a branches nor tags filter”