Skip to content

Create tag for normal release or hotfix #38

Create tag for normal release or hotfix

Create tag for normal release or hotfix #38

Workflow file for this run

## REFER DOCS:
# https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines
# https://semver.org/
# https://github.com/semantic-release/semantic-release
# https://github.com/mathieudutour/github-tag-action#bumping
################################################
# GITHUB ACTION WORKFLOW NAME
################################################
name: Practera Release Tag/Branch Creation
################################################
# GITHUB ACTION EVENT TRIGGER
################################################
on:
workflow_dispatch:
inputs:
RELEASE_BRANCH:
description: '# Branch name that has code to release!'
required: true
default: ''
HOTFIX_TAG:
description: '# Optional, if Hotfix Release, then mandatory to input recent tag version (include prefix - v as well) deployed to live otherwise ignore this input'
default: 'false'
################################################
# GITHUB ACTION JOBS
################################################
jobs:
create-release-tag:
name: create-release-tag
runs-on: ubuntu-latest
timeout-minutes: 15
################################################
# GITHUB ACTIONS GLOBAL ENV VARIABLES
################################################
env:
ENV : live # Valid values are dev,test,live only
STACK_NAME: live # Valid values are au,us,uk,p2,lf,nu,p1-sandbox,p1-stage,p2-sandbox,shared,p2-usa only
ROOTSTACK: app-v2
CFNS3BucketName: devops-cfn-templates
PRIVATES3BucketName: devops-shared-private
STATUSREPORTS3Bucket: deployment-status.practera.com
VERSION_FILE: package.json
RELEASE_BRANCH: ${{ github.event.inputs.RELEASE_BRANCH }}
HOTFIX_TAG: ${{ github.event.inputs.HOTFIX_TAG }}
################################################
# GITHUB REPO CHECKOUT
################################################
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
ref: ${{ github.event.inputs.RELEASE_BRANCH }}
################################################
# AWS CLI CONFIGURATION - DEVOPS
################################################
- name: Configure AWS credentials from $STACK_NAME account
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.DEVOPS_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEVOPS_AWS_SECRET_ACCESS_KEY }}
aws-region: ap-southeast-2
################################################
# NEW TAG DEFINED FOR RELEASE PROCESS
################################################
- name: New tag defined for release process
if: env.HOTFIX_TAG == 'false'
run: |
aws s3 cp s3://$STATUSREPORTS3Bucket/scripts/create-tag-release.sh create-tag-release.sh
chmod +x ./create-tag-release.sh
./create-tag-release.sh
##########################################################
# NEW TAG DEFINED FOR RELEASE PROCESS - For Hotfix Release
###########################################################
- name: New tag defined for release process
if: env.HOTFIX_TAG != 'false'
run: |
aws s3 cp s3://$STATUSREPORTS3Bucket/scripts/create-hotfix-tag-release.sh create-hotfix-tag-release.sh
chmod +x ./create-hotfix-tag-release.sh
./create-hotfix-tag-release.sh
################################################
# BUMP VERSION AND PUSH TAGS
################################################
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v5.5
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ env.RELEASE_TAG_VERSION }}
tag_prefix: v
release_branches: ${{ github.event.inputs.RELEASE_BRANCH }}
create_annotated_tag: true
# custom_release_rules: hotfix:patch,pre-feat:preminor,bug:patch:Bug Fixes,chore:patch:Chores
dry_run: false
################################################
# CREATE GIT TAGS FOR RELEASE PROCESS
################################################
- name: Create a GitHub release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag_version.outputs.new_tag }}
release_name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
# ##########################################################
# # SLACK NOTIFICATION FOR SUCCESS
# ##########################################################
- name: Slack Notification
if: ${{ success() }} # Pick up events even if the job fails or is canceled.
uses: 8398a7/action-slack@v3
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
MATRIX_CONTEXT: ${{ toJson(matrix) }} # required
with:
status: ${{ job.status }}
author_name: Release ${{ steps.tag_version.outputs.new_tag }} created for ${{ env.ROOTSTACK }} for deployment to ${{ env.ENV }} environemnt in ${{ env.STACK_NAME }} AWS account. git previous tag id ${{ env.CURRENT_TAG_VERSION }}
mention: 'here'
if_mention: failure,cancelled
job_name: create-release-tag # Match the name above.
fields: repo,commit,eventName,ref,workflow,message,author,job,took
custom_payload: |
{
username: 'GitHub Action CI WorkFlow',
icon_emoji: ':github:',
attachments: [{
color: '${{ job.status }}' === 'success' ? 'good' : ${{ job.status }}' === 'failure' ? 'danger' : 'warning',
text:
`${process.env.AS_REPO}\n
${process.env.AS_COMMIT}\n
${process.env.AS_EVENT_NAME}\n
@${process.env.AS_REF}\n
@${process.env.AS_WORKFLOW}\n
${process.env.AS_MESSAGE}\n
${process.env.AS_AUTHOR}\n
${process.env.AS_JOB}\n
${process.env.AS_TOOK}`,
}]
}
# ##########################################################
# # SLACK NOTIFICATION FOR FAILURE
# ##########################################################
- name: Slack Notification
if: ${{ failure() }} # Pick up events even if the job fails or is canceled.
uses: 8398a7/action-slack@v3
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
MATRIX_CONTEXT: ${{ toJson(matrix) }} # required
with:
status: ${{ job.status }}
author_name: create tag failed; package.json version id ${{env.NEW_TAG_VERSION}}; git latest tag id ${{env.CURRENT_TAG_VERSION}} mismatch - ${{ env.ERR_MSG }}
mention: 'here'
if_mention: failure,cancelled
job_name: create-release-tag # Match the name above.
fields: repo,commit,eventName,ref,workflow,message,author,job,took
custom_payload: |
{
username: 'GitHub Action CI WorkFlow',
icon_emoji: ':github:',
attachments: [{
color: '${{ job.status }}' === 'success' ? 'good' : ${{ job.status }}' === 'failure' ? 'danger' : 'warning',
text:
`${process.env.AS_REPO}\n
${process.env.AS_COMMIT}\n
${process.env.AS_EVENT_NAME}\n
@${process.env.AS_REF}\n
@${process.env.AS_WORKFLOW}\n
${process.env.AS_MESSAGE}\n
${process.env.AS_AUTHOR}\n
${process.env.AS_JOB}\n
${process.env.AS_TOOK}`,
}]
}