Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my github action on paths also triggered when pushing a new tag?

I have the following config in my yml file:

name: code pipeline
run-name: code pipeline run by ${{ github.actor }}
on:
  push:
    paths:
      - my-code/**
      - scripts/some-other-script.py
      - .github/workflows/my-workflow.yml

And for some reason that workflow is always triggered even if I am just pushing a new tag. This is more a minor annoyance than a blocker, but I thought it would be nice to understand this better, because I am obviously missing something here. Thank you for your help!

I would expect that this workflow is only triggered on code changes anywhere in the given paths.

like image 719
Jonas Behr Avatar asked Sep 16 '25 22:09

Jonas Behr


1 Answers

As per actions docs:

When using the push event, you can configure a workflow to run on specific branches or tags.

If you define only tags/tags-ignore or only branches/branches-ignore, the workflow won't run for events affecting the undefined Git ref. If you define neither tags/tags-ignore or branches/branches-ignore, the workflow will run for events affecting either branches or tags. If you define both branches/branches-ignore and paths, the workflow will only run when both filters are satisfied.

At the same time, path filters are not evaluated for pushes of tags.

It means that if you want to trigger the workflow only for code changes, you need to add the explicit parameter branches, e.g. like this:

name: code pipeline
run-name: code pipeline run by ${{ github.actor }}
on:
  push:
    branches:
      - '**'
    paths:
      - my-code/**
      - scripts/some-other-script.py
      - .github/workflows/my-workflow.yml
like image 119
Kirill Bubochkin Avatar answered Sep 19 '25 16:09

Kirill Bubochkin