Today, we will be attempting to create Environments, Git Tags & Releases, & build Docker images based on environments
We will be creating several environments today.
- DEV
- UAT
- PROD
In order to create the above environments, go to Settings > Environments > New Environment. Input the New Environment e.g. DEV > Configure Environment.
Ideally, we should enable "Required Reviewers" & "Prevent Self-Review", which requires engineers to get approval from other team members who will need to approve the pipeline before the application is deployed to that particular environment. This is exceptionally important in PROD environment.
You can also set Environment Secrets and Variables, which will override Repository Secrets and Variables, which will be specific to that particular environment.
Another key feature would be to enable Deployment Branches & Tags for particular branches. A standard would be for example:
- DEV --> Any branches can be deployed to DEV env
- UAT --> Only release/** branches can be deployed to UAT env
- PROD --> Only release/** & hotfix/** branches can be deployed to PROD env
A sample in DEV:
A sample in UAT:
A sample in PROD:
Tags will be used when we are preparing for UAT and PROD environments for Docker images. In DEV environments, we can stick to "latest" tag, but in UAT and PROD, we can incrementally increase the version with each releases e.g. v1.0.1 --> v1.0.2 --> v1.1.1 --> v.1.1.2 etc.
In order to view tags, in the main page, click the "tags" button next to "branches" button.
Here, you will see all the tags available. To create tags, go to "Releases" tab and click "Draft a new release"
You can input a version tag from the tag dropdown and click "Create new tag". Ensure that you choose the right branch as the target.
Once done, click "Publish Release"
We will next create 2 yaml files - 1 for CI and 1 for CD, with the CI file making workflow calls to the CD file to allow automatic deployments to the target environment based on your branch.