Auto-tagging without creating a circular workflow

Hi there!

I’m trying to setup a continuous delivery structure that essentially just tags and deploys any commits made to master.

Here is the rough idea:

workflows:
  test-tag:
    jobs:
      - test:
          filters:
            branches:
              only: /master/
      - tag:
          requires:
            - test

  deploy:
    jobs:
      - production-deploy:
          filters:
            tags:
              only: /^v[0-9|\.]+$/
            branches:
              ignore: /.*/

With the test-tag workflow, what happens is whenever a commit is made to master it will run tests and then tag the current state of the branch to something like v1.1.1. The deploy workflow will then respond to the new tag being created and deploy it.

The problem is that when the tagging happens, it creates a commit+push to master, thus re-triggering the test-tag workflow again, leading to a circular workflow!

I’m aware of [ci-skip] but I want to avoid this because it can create unexpected behaviours when other developers are syncing their branches with master as it will skip running tests on that initial merge.

Would love to hear if there’s some solution to this problem, or if perhaps I’m structuring my workflow in a strange way.

Cheers!

Just thinking out loud here. I wonder if when you make your new commit, you could also tag it as ci-commit, and then git push --follow-tags. Then when you handle a push on master in CI, make sure you ignore the ci-commit tag.

@halfer yes ive considered this but im not a huge fan of manually implementing an ignore rule… although this is definitely a possible solution. as an aside, how would you effectively exit out of the workflow?

No, I was thinking that maybe the test job could have an ignore filter on tags. If you try that, I seem to recall it’s a bit fiddly - combined rules in the same job do not always work as one would expect. Nevertheless, give it a try?

Ah I see what you mean! Actually, tags are filtered by default unless you explicitly filter them IN. The problem is that when my workflow automatically tags and commits master, it’ll kickoff the test job again (because of the commit to master again)

I was wondering if you can do a tags: ignore: device? I seem to recall though that the tags/branches are ORed and not ANDed, so that might not work.