Is there a possibility to tigger a github action only if a new version (which comes with a new tag) is pushed? I don't want run them on every push into master, but I also want to avoid creating a release branch.
Is there a possibility to tigger a github action only if a new version (which comes with a new tag) is pushed? I don't want run them on every push into master, but I also want to avoid creating a release branch.
Use the following syntax:
on:
push:
# Pattern matched against refs/tags
tags:
- '*' # Push events to every tag not containing /
For hierarchical tags:
on:
push:
# Pattern matched against refs/tags
tags:
- '**' # Push events to every tag including hierarchical tags like v1.0/beta
I got it to work with
on:
push:
tags:
- '*'
I found out that if the tag was previously created (locally) before the workflow was created, no matter how many times I deleted and re-pushed the tag, it would not trigger until I deleted the tag locally and recreated it. The action does not seem to work for tags created before the workflow.
The goal is to trigger a workflow when a tag is pushed, e.g. doing something like:
git tag v1.0.0
git push origin v1.0.0
In the workflow file:
e.g. ci.yml
name: CI
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
This will run if someone pushes a semantic versioned tag to the GitHub repo.
One mistake I made was when migrating from Travis CI to GitHub Actions is that I incorrectly used
'^v[0-9]+\.[0-9]+\.[0-9]+'
as the pattern, which is WRONG. So check your pattern syntax if the workflow is not being triggered.