I have a react app with 2 environemnts in netlify. Until now, I was managing the Continuous deployments using 2 branches but sometimes it gets very messy when doing hotfixes. I would like to set up a Continuous Deployment system where it will deploy on git tags on the same branch instead of having different branches. I think it's the best approach as the code will always be common if it's the same branch.
After some research, I have found that it could be done using github actions (we are already using this for git) and the netlify cli to build based on tags.
From the documentation it seems I should use:
on: push
name: Publish on Netlify
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Publish
uses: netlify/actions/build@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_BASE: site
NETLIFY_CMD: npm build
NETLIFY_DIR: site/_build
This comes from https://github.com/netlify/actions/tree/master/build
The code for working with the tags in github actions is:
on:
push:
tags:
- '*'
It was posted on this article: https://github.community/t5/GitHub-Actions/How-to-run-GitHub-Actions-Workflow-only-for-new-tags/td-p/29413#
I understand that it should be like this:
on:
push:
tags:
- '*'
name: Publish on Netlify
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Publish
uses: netlify/actions/build@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_BASE: site
NETLIFY_CMD: npm build
NETLIFY_DIR: site/_build
But it's not working. Any ideas?