Currently I have 2 Github Action. One for production release, and the other one for staging release.
When I push a tag in production branch it triggers the CI/CD:
name: Deploy production
on:
push:
tags:
- 'v*'
And when I "simply" push a commit to the develop branch it trigger the other CI/CD:
name: Deploy staging
on:
push:
branches:
- develop
What I would like to achieve now, is to trigger production and staging actions with different, but similar git tag. I only know how to write down the "filter" in regex, but not how should I implement it in Github Actions.
For production:
/^v\d{1,2}\.\d{1,2}\.\d{1,2}/i
This captures strings from v0.0.0
up to v99.99.99
For staging:
/^v\d{1,2}\.\d{1,2}\.\d{1,2}-rc\.\d{1,2}/i
This captures strings from v0.0.0-rc.0
up to v99.99.99-rc.99
My best guesses are these:
Production
name: Deploy production
on:
push:
branches:
- main
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
Staging
name: Deploy production
on:
push:
branches:
- develop
tags:
- 'v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+'
May I ask for help, how to implement my idea properly?
Sources:
There isn't much to answer here, you've got tag filters that appear to be what you're after. The only thing to point out here is that the branches:
condition is a separate check. The tag filter and the branches are an OR, not an AND. So it's either up to you to make sure you only ever tag commits in those branches, or to include a step in an initialising job that checks that the triggering tag is on the expected branch.