From 481fc68cd5386ddea561ca5154b6708f3c9fb46b Mon Sep 17 00:00:00 2001 From: logoutdhaval Date: Mon, 27 Nov 2023 14:56:19 +0530 Subject: [PATCH] [PHEE-477] Create an orb that fetches the docker images and do helm upgrade --- .circleci/config.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index afe9901..fc96a25 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -56,7 +56,13 @@ jobs: command: | ./gradlew bootJar docker build -t openmf/ph-ee-connector-mpesa:latest . - + if [ "$CIRCLE_BRANCH" != "master" ]; then + PR_NUMBER=$(basename $CIRCLE_PULL_REQUEST) + PR_TITLE=$(curl -sSL "https://api.github.com/repos/openmf/$CIRCLE_PR_REPONAME/pulls/$PR_NUMBER" | jq -r '.title') + JIRA_STORY=$(echo $PR_TITLE | cut -d "[" -f2 | cut -d "]" -f1 | tr '[A-Z]' '[a-z]') + if [ -z "$JIRA_STORY" ]; then echo "Invalid PR title" && exit 1; else echo "Ticket NO: $JIRA_STORY"; fi + docker image tag openmf/$CIRCLE_PR_REPONAME:latest openmf/$CIRCLE_PR_REPONAME:$JIRA_STORY + fi # Log in to DockerHub using environment variables - run: name: Login to DockerHub @@ -65,7 +71,16 @@ jobs: # Push the Docker image to DockerHub - run: name: Push Docker image to DockerHub - command: docker push openmf/ph-ee-connector-mpesa:latest + command: | + if [ "$CIRCLE_BRANCH" = "master" ]; then + docker push openmf/ph-ee-connector-mpesa:latest + fi + if [ "$CIRCLE_BRANCH" != "master" ]; then + PR_NUMBER=$(basename $CIRCLE_PULL_REQUEST) + PR_TITLE=$(curl -sSL "https://api.github.com/repos/openmf/$CIRCLE_PR_REPONAME/pulls/$PR_NUMBER" | jq -r '.title') + JIRA_STORY=$(echo $PR_TITLE | cut -d "[" -f2 | cut -d "]" -f1 | tr '[A-Z]' '[a-z]') + docker push openmf/$CIRCLE_PR_REPONAME:${JIRA_STORY} + fi workflows: version: 2