Skip to content

Commit d49965e

Browse files
authored
Merge pull request #2539 from intersective/fix/tag-creation-ci
fix: tag ci workflow
2 parents 03eb7d8 + 3f6170b commit d49965e

File tree

1 file changed

+73
-160
lines changed

1 file changed

+73
-160
lines changed

.github/workflows/create-tag.yml

Lines changed: 73 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -1,197 +1,110 @@
1-
## REFER DOCS:
2-
# https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines
3-
# https://semver.org/
4-
# https://github.com/semantic-release/semantic-release
5-
# https://github.com/mathieudutour/github-tag-action#bumping
6-
7-
1+
---
82
################################################
93
# GITHUB ACTION WORKFLOW NAME
104
################################################
11-
name: Practera Release Tag/Branch Creation
12-
5+
name: "Create tag for normal release or hotfix"
136

147
################################################
158
# GITHUB ACTION EVENT TRIGGER
169
################################################
17-
on:
10+
on:
1811
workflow_dispatch:
1912
inputs:
20-
RELEASE_BRANCH:
21-
description: '# Branch name that has code to release!'
13+
IS_HOTFIX:
14+
type: choice
15+
description: "Is a hotfix or not."
2216
required: true
23-
default: ''
17+
default: "false"
18+
options:
19+
- "false"
20+
- "true"
2421
HOTFIX_TAG:
25-
description: '# Optional, if Hotfix Release, then mandatory to input recent tag version (include prefix - v as well) deployed to live otherwise ignore this input'
26-
default: 'false'
22+
description: "Tag to calculate creation of hotfix."
23+
default: ""
24+
IS_MAJOR:
25+
type: choice
26+
description: "Is a major release?"
27+
required: true
28+
default: "false"
29+
options:
30+
- "false"
31+
- "true"
32+
IS_MINOR:
33+
type: choice
34+
description: "Is a minor release?"
35+
required: true
36+
default: "false"
37+
options:
38+
- "false"
39+
- "true"
40+
IS_PATCH:
41+
type: choice
42+
description: "Is a patch release?"
43+
required: true
44+
default: "false"
45+
options:
46+
- "false"
47+
- "true"
2748

2849
################################################
29-
# GITHUB ACTION JOBS
30-
################################################
50+
# GITHUB ACTION JOB
51+
################################################
3152
jobs:
32-
create-release-tag:
33-
name: create-release-tag
34-
runs-on: ubuntu-latest
53+
create-tag:
54+
permissions: write-all
3555
timeout-minutes: 15
36-
56+
runs-on: ubuntu-latest
3757

3858
################################################
3959
# GITHUB ACTIONS GLOBAL ENV VARIABLES
4060
################################################
4161
env:
42-
ENV : live # Valid values are dev,test,live only
43-
STACK_NAME: live # Valid values are au,us,uk,p2,lf,nu,p1-sandbox,p1-stage,p2-sandbox,shared,p2-usa only
44-
ROOTSTACK: app-v2
45-
CFNS3BucketName: devops-cfn-templates
46-
PRIVATES3BucketName: devops-shared-private
62+
ENV: live
4763
STATUSREPORTS3Bucket: deployment-status.practera.com
48-
VERSION_FILE: package.json
49-
RELEASE_BRANCH: ${{ github.event.inputs.RELEASE_BRANCH }}
50-
HOTFIX_TAG: ${{ github.event.inputs.HOTFIX_TAG }}
51-
52-
64+
REGION: ap-southeast-2
65+
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
66+
steps:
5367

5468
################################################
5569
# GITHUB REPO CHECKOUT
5670
################################################
57-
steps:
5871
- uses: actions/checkout@v4
5972
with:
60-
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
61-
ref: ${{ github.event.inputs.RELEASE_BRANCH }}
62-
73+
fetch-depth: 0
74+
ref: release/live # branch for release
6375

6476
################################################
65-
# AWS CLI CONFIGURATION - DEVOPS
66-
################################################
67-
- name: Configure AWS credentials from $STACK_NAME account
68-
uses: aws-actions/configure-aws-credentials@v4
69-
with:
70-
aws-access-key-id: ${{ secrets.DEVOPS_AWS_ACCESS_KEY_ID }}
71-
aws-secret-access-key: ${{ secrets.DEVOPS_AWS_SECRET_ACCESS_KEY }}
72-
aws-region: ap-southeast-2
73-
74-
77+
# AWS credentials setup
7578
################################################
76-
# NEW TAG DEFINED FOR RELEASE PROCESS
77-
################################################
78-
- name: New tag defined for release process
79-
if: env.HOTFIX_TAG == 'false'
79+
- name: Get AWS Organization Number
80+
id: AWS_ORG
8081
run: |
81-
aws s3 cp s3://$STATUSREPORTS3Bucket/scripts/create-tag-release.sh create-tag-release.sh
82-
chmod +x ./create-tag-release.sh
83-
./create-tag-release.sh
84-
82+
CENTRALIZED=$(echo $AWS_ACCOUNT_ID | jq -r .CENTRALIZED)
83+
echo "::add-mask::$CENTRALIZED"
84+
echo "CENTRALIZED=$CENTRALIZED" >> $GITHUB_OUTPUT
85+
- name: Configure AWS Credentials from Centralized account
86+
uses: ./.github/actions/aws-oidc
87+
with:
88+
role-to-assume: arn:aws:iam::${{ steps.AWS_ORG.outputs.CENTRALIZED }}:role/github-restricted-role-to-assume
89+
region: ${{ env.REGION }}
8590

86-
##########################################################
87-
# NEW TAG DEFINED FOR RELEASE PROCESS - For Hotfix Release
88-
###########################################################
89-
- name: New tag defined for release process
90-
if: env.HOTFIX_TAG != 'false'
91+
################################################
92+
# Download script from s3 bucket
93+
################################################
94+
- name: Download script file
9195
run: |
92-
aws s3 cp s3://$STATUSREPORTS3Bucket/scripts/create-hotfix-tag-release.sh create-hotfix-tag-release.sh
93-
chmod +x ./create-hotfix-tag-release.sh
94-
./create-hotfix-tag-release.sh
95-
96+
aws s3 cp s3://$STATUSREPORTS3Bucket/scripts/tag-releasev2.sh tag-releasev2.sh
97+
chmod +x ./tag-releasev2.sh
9698
9799
################################################
98-
# BUMP VERSION AND PUSH TAGS
99-
################################################
100-
- name: Bump version and push tag
101-
id: tag_version
102-
uses: mathieudutour/[email protected]
103-
with:
104-
github_token: ${{ secrets.GITHUB_TOKEN }}
105-
custom_tag: ${{ env.RELEASE_TAG_VERSION }}
106-
tag_prefix: v
107-
release_branches: ${{ github.event.inputs.RELEASE_BRANCH }}
108-
create_annotated_tag: true
109-
# custom_release_rules: hotfix:patch,pre-feat:preminor,bug:patch:Bug Fixes,chore:patch:Chores
110-
dry_run: false
111-
112-
100+
# Run script to create tag
113101
################################################
114-
# CREATE GIT TAGS FOR RELEASE PROCESS
115-
################################################
116-
- name: Create a GitHub release
117-
uses: actions/create-release@v1
118-
env:
119-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
120-
with:
121-
tag_name: ${{ steps.tag_version.outputs.new_tag }}
122-
release_name: Release ${{ steps.tag_version.outputs.new_tag }}
123-
body: ${{ steps.tag_version.outputs.changelog }}
124-
125-
126-
127-
# ##########################################################
128-
# # SLACK NOTIFICATION FOR SUCCESS
129-
# ##########################################################
130-
- name: Slack Notification
131-
if: ${{ success() }} # Pick up events even if the job fails or is canceled.
132-
uses: 8398a7/action-slack@v3
133-
env:
134-
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
135-
MATRIX_CONTEXT: ${{ toJson(matrix) }} # required
136-
with:
137-
status: ${{ job.status }}
138-
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 }}
139-
mention: 'here'
140-
if_mention: failure,cancelled
141-
job_name: create-release-tag # Match the name above.
142-
fields: repo,commit,eventName,ref,workflow,message,author,job,took
143-
custom_payload: |
144-
{
145-
username: 'GitHub Action CI WorkFlow',
146-
icon_emoji: ':github:',
147-
attachments: [{
148-
color: '${{ job.status }}' === 'success' ? 'good' : ${{ job.status }}' === 'failure' ? 'danger' : 'warning',
149-
text:
150-
`${process.env.AS_REPO}\n
151-
${process.env.AS_COMMIT}\n
152-
${process.env.AS_EVENT_NAME}\n
153-
@${process.env.AS_REF}\n
154-
@${process.env.AS_WORKFLOW}\n
155-
${process.env.AS_MESSAGE}\n
156-
${process.env.AS_AUTHOR}\n
157-
${process.env.AS_JOB}\n
158-
${process.env.AS_TOOK}`,
159-
}]
160-
}
161-
162-
163-
164-
# ##########################################################
165-
# # SLACK NOTIFICATION FOR FAILURE
166-
# ##########################################################
167-
- name: Slack Notification
168-
if: ${{ failure() }} # Pick up events even if the job fails or is canceled.
169-
uses: 8398a7/action-slack@v3
102+
- name: Run script
103+
run: |
104+
./tag-releasev2.sh
170105
env:
171-
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
172-
MATRIX_CONTEXT: ${{ toJson(matrix) }} # required
173-
with:
174-
status: ${{ job.status }}
175-
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 }}
176-
mention: 'here'
177-
if_mention: failure,cancelled
178-
job_name: create-release-tag # Match the name above.
179-
fields: repo,commit,eventName,ref,workflow,message,author,job,took
180-
custom_payload: |
181-
{
182-
username: 'GitHub Action CI WorkFlow',
183-
icon_emoji: ':github:',
184-
attachments: [{
185-
color: '${{ job.status }}' === 'success' ? 'good' : ${{ job.status }}' === 'failure' ? 'danger' : 'warning',
186-
text:
187-
`${process.env.AS_REPO}\n
188-
${process.env.AS_COMMIT}\n
189-
${process.env.AS_EVENT_NAME}\n
190-
@${process.env.AS_REF}\n
191-
@${process.env.AS_WORKFLOW}\n
192-
${process.env.AS_MESSAGE}\n
193-
${process.env.AS_AUTHOR}\n
194-
${process.env.AS_JOB}\n
195-
${process.env.AS_TOOK}`,
196-
}]
197-
}
106+
IS_HOTFIX: ${{ github.event.inputs.IS_HOTFIX }}
107+
HOTFIX_TAG: ${{ github.event.inputs.HOTFIX_TAG }}
108+
IS_MAJOR: ${{ github.event.inputs.IS_MAJOR }}
109+
IS_MINOR: ${{ github.event.inputs.IS_MINOR }}
110+
IS_PATCH: ${{ github.event.inputs.IS_PATCH }}

0 commit comments

Comments
 (0)