Skip to content

Commit 9e70471

Browse files
authored
feat: add gh workflow for auto release ticket creation (#658)
Addresses https://sendbird.atlassian.net/browse/CLNP-176 As a initiation of the automating release process project, - Added a new gh workflow file to receive a signal from outside of Github e.g. Slack / GIthub CLI / Other 3party tools - Modified the Circle CI config to take an advantage of existing Jira ticket creation pipeline
1 parent 4b0c84e commit 9e70471

File tree

2 files changed

+118
-2
lines changed

2 files changed

+118
-2
lines changed

.circleci/config.yml

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22
# See: https://circleci.com/docs/2.0/configuration-reference
33
version: 2.1
44

5+
# MARK: Orbs
6+
orbs:
7+
slack: circleci/[email protected]
8+
9+
executors:
10+
node-executor:
11+
docker:
12+
- image: cimg/node:16.19.1
13+
14+
# MARK: Worflow parameters
15+
parameters:
16+
run_workflow_create_ticket:
17+
type: boolean
18+
default: false
19+
520
commands:
621
command-lint:
722
steps:
@@ -17,13 +32,22 @@ commands:
1732
name: UIKit for React test
1833
command: yarn run test
1934
no_output_timeout: 15m
35+
clone_deployment_script:
36+
steps:
37+
- run:
38+
name: Git - Clone deployment scripts
39+
when: always
40+
environment:
41+
SDK_DEPLOYMENT_BOT_EMAIL: ${{ secrets.SDK_DEPLOYMENT_BOT_EMAIL }}
42+
command: |
43+
git config --global user.email $SDK_DEPLOYMENT_BOT_EMAIL
44+
git clone --depth 1 --branch 1.0.1 [email protected]:sendbird/sdk-deployment.git ~/sdk-deployment
2045
2146
# Define a job to be invoked later in a workflow.
2247
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
2348
jobs:
2449
job-lint_and_test:
25-
docker:
26-
- image: cimg/node:16.19.1
50+
executor: node-executor
2751
parallelism: 4
2852
resource_class: large
2953
steps:
@@ -43,10 +67,67 @@ jobs:
4367
key: uikit-yarn-dependencies-{{ checksum "yarn.lock" }}
4468
paths:
4569
- ./.yarn/cache
70+
create-ticket:
71+
executor: node-executor
72+
steps:
73+
- checkout
74+
- clone_deployment_script
75+
- run:
76+
name: Extract release version
77+
command: |
78+
release_version=$(python3 ~/sdk-deployment/scripts/v1.2/extract_version.py --branch_name $CIRCLE_BRANCH)
79+
echo "export RELEASE_VERSION=$release_version" >> $BASH_ENV
80+
source $BASH_ENV
81+
- run:
82+
name: Jira - Create release version
83+
command: |
84+
python3 ~/sdk-deployment/scripts/v1.2/create_version.py\
85+
--jira_auth_user $JIRA_AUTH_USER\
86+
--jira_auth_api_token $JIRA_AUTH_API_TOKEN\
87+
--project SDKRLSD\
88+
--name js_uikit@$RELEASE_VERSION\
89+
--description 'Created by automation @ $CIRCLE_PROJECT_REPONAME'
90+
- run:
91+
name: Jira - Create release ticket
92+
command: |
93+
release_ticket_key=$(python3 ~/sdk-deployment/scripts/v1.2/create_ticket.py\
94+
--jira_auth_user $JIRA_AUTH_USER\
95+
--jira_auth_api_token $JIRA_AUTH_API_TOKEN\
96+
--project SDKRLSD\
97+
--version js_uikit@$RELEASE_VERSION\
98+
--title "[UIKit] js_uikit@$RELEASE_VERSION"\
99+
--description 'Created by automation @ $CIRCLE_PROJECT_REPONAME'\
100+
--source_repo $CIRCLE_PROJECT_REPONAME\
101+
--source_branch $CIRCLE_BRANCH\
102+
--source_jira_project CORE\
103+
--source_jira_version js_uikit@$RELEASE_VERSION)
104+
echo "export RELEASE_TICKET_KEY=$release_ticket_key" >> $BASH_ENV
105+
source $BASH_ENV
106+
- slack/notify:
107+
channel: $SLACK_RELEASE_APPOVER_CHANNEL_ID # sdk-release-approver
108+
event: pass
109+
custom: |
110+
{
111+
"blocks": [
112+
{
113+
"type": "section",
114+
"text": {
115+
"type": "mrkdwn",
116+
"text": "@chat-approver <https://sendbird.atlassian.net/browse/$RELEASE_TICKET_KEY|🔖 UIKit JS $RELEASE_VERSION release ticket> has been created!"
117+
}
118+
}
119+
]
120+
}
121+
46122
47123
# Invoke jobs via workflows
48124
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
49125
workflows:
50126
built-and-test:
51127
jobs:
52128
- job-lint_and_test
129+
create-release-ticket-workflow:
130+
when: << pipeline.parameters.run_workflow_create_ticket >>
131+
jobs:
132+
- create-ticket:
133+
context: sdk-release-bot
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Release ticket creation on manual workflow trigger
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
branch_name:
6+
description: 'Release target branch name'
7+
required: true
8+
9+
jobs:
10+
trigger-release-ticket-creation:
11+
name: Trigger release ticket creation
12+
runs-on: ubuntu-latest
13+
# The branch name should starts with 'release/v'
14+
if: startsWith(github.event.inputs.branch_name, 'release/v')
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v2
18+
- name: Trigger CircleCI Job
19+
run: |
20+
API_RESULT=$(curl --request POST \
21+
--url "https://circleci.com/api/v2/project/gh/${{ github.repository }}/pipeline" \
22+
--header "Circle-Token: ${{ secrets.CIRCLE_CI_API_TOKEN }}" \
23+
--header "content-type: application/json" \
24+
--data '{
25+
"branch": "${{ github.event.inputs.branch_name }}",
26+
"parameters": {
27+
"run_workflow_create_ticket": true,
28+
}
29+
}')
30+
echo "API_RESULT: ${API_RESULT}"
31+
CIRCLE_CI_JOB_NUMBER=$(echo "${API_RESULT}" | jq -r '.number')
32+
echo "::set-output name=DEPLOY_COMMENT_BODY::https://app.circleci.com/pipelines/github/${{ github.repository }}/$CIRCLE_CI_JOB_NUMBER"
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
CIRCLE_CI_API_TOKEN: ${{ secrets.CIRCLE_CI_API_TOKEN }}

0 commit comments

Comments
 (0)