Skip to content

Commit

Permalink
[PHEE-477] Create an orb that fetches the docker images and do helm u…
Browse files Browse the repository at this point in the history
…pgrade (#145)

* jira story image push

* image push

* test

* PHEE-477 Create an orb that fetches the docker images and do helm upgrade

* imported orb

* fixed the issue

* fixed image push issue

* if check for master

* test

* use orb as job

* change in github template
  • Loading branch information
logoutdhaval authored Nov 27, 2023
1 parent 848b174 commit 608ebd3
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 33 deletions.
69 changes: 39 additions & 30 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ orbs:
helm: circleci/[email protected]
aws-eks: circleci/[email protected]
kubernetes: circleci/[email protected]
mifos-orb: mifos/docker-image-availability-check-and-upgrade@dev:first
executors:
docker-executor:
docker:
Expand Down Expand Up @@ -67,10 +68,17 @@ jobs:
- run:
name: Build Docker image
command: |
#Check for PR title Validity
./gradlew checkstyleMain
./gradlew clean bootJar
docker build -t openmf/ph-ee-connector-channel:latest .
docker build -t openmf/$CIRCLE_PR_REPONAME: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
Expand All @@ -79,9 +87,28 @@ jobs:
# Push the Docker image to DockerHub
- run:
name: Push Docker image to DockerHub
command: docker push openmf/ph-ee-connector-channel:latest


command: |
if [ "$CIRCLE_BRANCH" = "master" ]; then
docker push openmf/ph-ee-connector-channel: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
docker-image-availability-check-and-upgrade:
docker:
- image: cimg/python:3.10
steps:
- mifos-orb/docker-image-availability-check-and-upgrade:
namespace: paymenthub
chart: "https://fynarfin.io/images/ph-ee-g2psandbox-fynarfin/ph-ee-g2psandbox-fynarfin-0.2.0.tgz"
release-name: g2p-sandbox
add-repo: "https://fynarfin.io/images/ph-ee-g2psandbox-fynarfin"
cluster-name: "sit"
aws-region: "$REGION"
service-file-path: https://raw.githubusercontent.com/openMF/ph-ee-env-labs/master/.circleci/services.txt
build-and-host-engine:
docker:
- image: cimg/python:3.10
Expand Down Expand Up @@ -147,25 +174,6 @@ jobs:
- run: scp -o StrictHostKeyChecking=No -i b64encoded.pem index.yaml ph-ee-g2psandbox-fynarfin-0.2.0.tgz [email protected]:~/
- run: ssh -i b64encoded.pem -o StrictHostKeyChecking=No [email protected] sudo mv -t /apps/apache-tomcat-7.0.82/webapps/ROOT/images/ph-ee-g2psandbox-fynarfin index.yaml ph-ee-g2psandbox-fynarfin-0.2.0.tgz

upgrade-helm-chart:
docker:
- image: cimg/python:3.10
parameters:
cluster-name:
description: "sit"
type: string
steps:
- aws-eks/update-kubeconfig-with-authenticator:
cluster-name: "sit"
aws-region: "$REGION"
- helm/upgrade-helm-chart:
chart: "https://fynarfin.io/images/ph-ee-g2psandbox-fynarfin/ph-ee-g2psandbox-fynarfin-0.2.0.tgz"
release-name: g2p-sandbox
namespace: paymenthub
recreate-pods: true
add-repo: "https://fynarfin.io/images/ph-ee-g2psandbox-fynarfin"
wait: true
timeout: "300s"

test-chart-gov:
docker:
Expand Down Expand Up @@ -273,23 +281,24 @@ workflows:
context:
- AWS
- Helm
- upgrade-helm-chart:
cluster-name: sit
requires:
- build-host-g2p-fyn-chart
- docker-image-availability-check-and-upgrade:
context:
- AWS
- Helm
- slack
requires:
- build-host-g2p-fyn-chart
- test-chart-gov:
requires:
- upgrade-helm-chart
- docker-image-availability-check-and-upgrade
context:
- AWS
- Helm
- slack
- Ngrok
- test-chart-ams:
requires:
- upgrade-helm-chart
- docker-image-availability-check-and-upgrade
context:
- AWS
- Helm
Expand Down
8 changes: 5 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
## Description

* PR title should have jira ticket enclosed in `[]`.<br>
Format: ``` [jira_ticket] description```<br>
ex: [phee-123] PR title.
* Add a link to the Jira ticket.
* Describe the changes made and why they were made.
* Add a link to the design document or include the design bullet points related to this PR here.

_(Ignore if these details are present on the associated JIRA ticket)_

## Checklist

Please make sure these boxes are checked before submitting your pull request - thanks!
- [ ] Followed the PR title naming convention mentioned above.

- [ ] Design related bullet points or design document link related to this PR added in the description above.

Expand Down

0 comments on commit 608ebd3

Please sign in to comment.