I have an extremely common CI workflow, that I already implemented in some repositories with Gitlab CI, Bitbucket pipelines, Travis and Circle CI, and I can’t find ways to represent it with Github Actions:
* When I push to any branch it executes a bunch of unit tests. (That can easily be represented by a job)
* When I create a tag it should also do the same thing and, if all tests succeed, it should deploy the project (to NPM as example).
With most CI system it would simply be some config that says “only execute this job if we are on a tag” but it doesn’t seem to be possible with Github Actions. Or maybe I’m wrong and in that case please tell me.
So, does any one have a solution about this ?
Just for info here are a few solutions I thought about to implement that workflow that would not be satisfactory:
* Define two different workflows, one for normal branches and one for release: That would seem to be a very bad solution. First I would need to create two conditions regarding workflow triggering for those workflows to be mutually exclusive and the documentation about workflow triggering conditions is so bad currently that I’m not even sure it’s possible. Second that mean I would have to copy-paste my testing job to multiple workflows (as far as I know there is no way to share a job accross multiple workflows)
* Use step conditions (AKA “if”): Doesn’t seem to be a good idea. Here there are clearly different jobs that should be triggered or not depending on the situation.
* Try to use actions: Seems even worse. Actions seems to be designed as reusable pieces of code that do one thing, not non-reusable-project-dependant complete tasks.