Suggested a Git Workflow Architecture to Manage the Product Release — Git Case Study 1
Problem Statement:
You work as a DevOps Architect in Zendrix Softwares. The company has been struggling to manage their product releases. The releases should happen on the 25th of every month. Suggest a Git workflow architecture for this requirement. Simulate this workflow by creating pseudo code files and branches and upload the same to your GitHub account.
As a part of the solution, share the link to your GitHub repository.
Before moving this case study solution, if you have not checked the Git assignments, please check out these Git Assignment Solutions:
Create The Files & Push them to Git Hub Repository — Git Assignment 1
Create the Files in Separate Branches And Perform Stash & Unstash Operations — Git Assignment 2
Create & Delete the Branches in Git Hub from Local & Remote Repository — Git Assignment 3
Create Two Branches & Merge These Branches to the Master Branch — Git Assignment 4
Create a Git Workflow Architecture & Use Hotfix to Push a File — Git Assignment 5
Check the Git Hub Repository for this Assignment to Copy the Commands:
Proposed Git Case Study 1 Problem Solution
Follow these steps to implement a Git Workflow architecture to remove the product release struggle:
A. Suggested Case Study Workflow Architecture
In this case, we will create three separate branches “master”, “develop” & “feature”. The “develop” branch will be created from the “master” branch, while the “feature” branch will be created from the “develop” branch. Also, create three files such as “master.txt”, “develop.txt” & “feature.txt” in these respective branches.
After creating all the branches & files, we will merge the “feature” branch into the “develop” branch & after merging the “feature” branch, we will merge the “develop” branch into the “master” branch.
Merging all branches into a master means the final code is ready to release & company will easily release the final product on the 25th of every month using this strategy.
B. Create an EC2 Instance for Accessing the Git Environment
Step 1: Go to the “Services” section & search “EC2” here. Put the cursor over “EC2” & click on “Instances” here.
Step 2: Click on “Launch Instances”.
Step 3: Choose “Name” as “Git-Case-Study-1” in the “Name and tags” section.
Step 4: Choose “AMI” as “ubuntu”.
Step 5: Choose “Instance type” as “t2.micro”.
Step 6: Choose “key pair (name) — required” as “Demo”.
Step 7: In “Network Settings”, choose “Select existing security group” in the “Firewall (security groups)” & while choosing “Common security groups” as “launch-wizard-9”.
Step 8: Click on “Launch Instance” in the “Summary”.
Step 9: The “Instance” will be successfully launched, click on “hyperlink (i-000fa73460f04612d).
Step 10: The Instance “Git-Case-Study-1” will be in the “Running” State.
Step 11: Select the Instance & Click on “Connect”.
Step 12: Again, click on “Connect”.
Step 13: First, update the machine using the below-given command:
sudo apt-get update
Step 14: The machine will be successfully updated.
C. First Create a master.txt File in the Master Branch
Step 1: First, create a file named “master.txt” file using the below-given command:
nano master.txt
Step 2: Write the line here: “This is a master.txt file”.
Do “CTRL+X” to exit & press “Yes” to save the file from the keyboard. Press “enter” from the keyboard to completely exit from the “master.txt” file.
Step 3: Now, initialize the git environment using the below-given command:
git init
Step 4: Now, add or stage the file (master.txt) in “Git” using the below-given command:
git add master.txt
The “master.txt” file has been successfully staged.
Step 5: Commit the changes to the local machine using the below-given command:
git commit –m "committing master.txt file".
Step 6: Run the below-given command to check out the branch:
git branch
Step 7: Run the below-given command to check out the branch:
git checkout master
Run the below-given command to check how many files are present in the master branch:
ls
You will notice that “master.txt” will be shown here.
D. Create the develop branch with the develop.txt file
Step 1: First, we will create a develop branch using the below-given command:
git branch develop
Also, run the below-given command to check how many branches are present:
git branch
You will notice that the “develop” branch will be displayed here.
Step 2: To create the “develop.txt” file, we have to switch to the “develop” branch.
Use the below-given command to go to the “develop” branch:
git checkout develop
Step 3: Create the file using the below-given command:
nano develop.txt
Step 4: Write a line here: This is a develop.txt file
Do “CTRL+X” to exit & press “Yes” to save the file from the keyboard. Press “enter” from the keyboard to completely exit from the “develop.txt” file.
Step 5: Stage the “develop.txt” file using the below-given command:
git add develop.txt
Step 6: Commit the changes using the below-given command to git local directory:
git commit –m "committing develop.txt file"
D. Create the feature branch with the feature.txt file
Step 1: First, we will create a feature branch using the below-given command:
git branch feature
Also, run the below-given command to check how many branches are present:
git branch
You will notice that the “feature” branch will be displayed here.
Step 2: For creating the “feature.txt” file, we have to go to the “feature” branch.
Use the below-given command to go to the “feature” branch:
git checkout feature
Step 3: Create the file using the below-given command:
nano feature.txt
Step 4: Write a line here: This is a develop.txt file
Do “CTRL+X” to exit & press “Yes” to save the file from the keyboard. Press “enter” from the keyboard to completely exit from the “feature.txt” file.
Step 5: Stage the “feature.txt” file using the below-given command:
git add feature.txt
Step 6: Commit the changes using this command to git local directory:
git commit –m "committing feature.txt file"
E. Create a Git Hub Repository on a Git Hub Account & Upload the Git Workflow Architecture
Step 1: Login into your GitHub Account using your username & password.
Step 2: Click on “New”.
Step 3: Choose the following options during repository creation:
Repository name: Git-Case-Study-1
Description: Git-Case-Study-1
Choose “Public” Here.
Step 4: Choose the “Add a README file” option & click on “Create repository”.
Step 5: Repository (Git-Case-Study-1) has been successfully created.
Step 6: Click on “Add file > Upload files”.
Step 7: Click on “Choose your files”.
Step 8: Select the “Case Study Architecture Image” & click on “Open”.
Step 9: The file will be successfully uploaded, click on “Commit Changes”.
Step 10: The “Case Study Architecture” image will be successfully uploaded.
F. Add SSH Keys to Your Git Hub Account
Step 1: Go to “EC2 Instance (Git-Case-Study-1)” & go to the .ssh directory using the below-given command:
cd .ssh/
Step 2: Type the below-given command to generate the public & private keys:
ssh-keygen
Press “enter” from the keyboard three times.
A public & private key will be successfully generated.
Step 3: Run the below-given command to copy the “id_rsa.pub” content:
sudo cat id_rsa.pub
Step 4: Go to the “Git Hub Account” & click on “Profile picture”. Scroll down & click on “Settings”.
Step 5: Click on “SSH and GPG Keys”.
Step 6: Click on “New SSH Key”.
Step 7: Choose the following options here:
Title: SSH Keys
Key type: Authentication Key
Key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDe5RitJQ2oDtxT6HFzgFekE1f4EZX3vSgCTZTKhkDdjS7cTbsNAb1ZfQKgRgI9ZtPHgl0utozGvImrmuXkhRgqCIEBeBNJGe5gOBjp3iFs1RsbJFG5mdAi+VnMqWTyKi8FcZZx9OJ8wS7YMEnUOowsc2x+43wpQ0rGG2DBOsUbtDDSUoMG8M2jLfNZk8Km4pVM6jET4TpB01TTT0hhhDLCGQZVKGfD89wmfJrhLGnNGbkZfOziRv5UYRNlDbCNQgAVlPF+/m/UFDxBlrVWKVPxy96vpj/I4us7EniBcKBL7b57JBgS6rGZ0pNDqgh3zPN+vqJYytKmKD+oigu893ke6yuF1iQ2zgKAGXBNdPNpZCpX/tVJKETIjmjInWioJffunAyYSimJ0egDTt5hRMlaNUY9/VcAmOhSsAAn6XazknoJ17cNLOUxDyfsOeNroSTOcNZ6CV8d5klXUmt2Y5Gen1T+sGue7GfmmI8vsSqclsygplB52biCfXqVjY3oaG8= ubuntu@ip-172–31–39–87
Click on “Add SSH Key”.
Step 8: The “SSH Key” will be successfully added.
G. Fetch the Remote Repository to EC2 Instance
Here, we will first the remote repository (Git-Case-Study-1) to the local machine & push all local machine changes to the remote repository which is created on the “Git Hub” Account.
Step 1: First, you have to change the directory & come out from the .ssh directory using the below-given command:
cd ..
Step 2: Go to the “Git Hub Repo (Git-Case-Study-1) & click on “Code”. Go to “SSH” & copy the code by clicking on the icon.
Step 3: Run the below-given command to fetch the remote directory “Git-Case-Study-1”:
git remote add Git-Case-Study-1 git@github.com:visaltyagi/Git-Case-Study-1.git
Step 4: Run the below-given command to check whether the repository is fetched or not:
git remote -v
H. Push All the Branches to the Git Hub Account
Step 1: First, we will push the “master” branch to the remote repository (Git-Case-Study-1) using the below-given command:
git push Git-Case-Study-1 master
Type “yes” to continue. The “master” branch will be successfully pushed to the “Git Hub Account”.
Step 2: Go to the “Git Hub Account” & choose the “master” branch. The “master.txt” file will be shown.
Step 3: Now, we will push the “develop” branch to the remote repository (Git-Case-Study-1) using the below-given command:
git push Git-Case-Study-1 develop
The “develop” branch will be successfully pushed to the “Git Hub Account”.
Step 4: Go to the “Git Hub Account” & choose the “develop” branch. The “develop.txt” file will be shown.
Step 5: Now, we will push the “feature” branch to the remote repository (Git-Case-Study-1) using the below-given command:
git push Git-Case-Study-1 feature
The “feature” branch will be successfully pushed to the “Git Hub Account”.
Step 6: Go to the “Git Hub Account” & choose the “feature” branch. The “feature.txt” file will be shown.
I. Make Master Branch a Default Branch & Remove Main Branch from Git Hub Repository
Step 1: Go to the “Settings” in “Git-Case-Study-1”.
Step 2: Click on “Double Arrows” to switch the branch.
Step 3: Choose to “master” & click on “Update”.
Step 4: Click on “I understand, update the default branch”.
Step 5: Now, the default branch will be “master”.
Step 6: Click on “Code”.
Step 7: Click on the “4 Branches” hyperlink.
Step 8: Click on the “delete” icon.
Step 9: Now the “master” will be a default branch.
J. Merge All Branches to the master branch
Step 1: First, which branch we have accessed via the below-given command:
git branch
So, we are in the “feature” branch.
Step 2: Now, we will merge the “feature” branch into the “develop” branch. Go to the “develop” branch using the below-given command:
git checkout develop
We will successfully move to the “feature” branch.
Step 3: We will run the below-given command to merge the “feature” branch into the “develop” branch:
git merge feature
The “feature” branch will be successfully merged with the “develop” branch.
Step 4: First, we will go to the “master” branch using the below-given command:
git checkout master
We have successfully switched to the “master” branch.
Step 5: Now, we will merge the “develop” branch into the “master” branch. Go to the “master” branch using the below-given command:
git merge develop
Now, both “develop.txt” & “feature.txt” has been successfully moved to the “master” branch.
K. Again, Push All the Changes to the Develop & Master Branch in the Remote Repository
Step 1: Push all “develop” branch changes to remote repository “Git-Case-Study-1” using the below-given command:
git push Git-Case-Study-1 develop
Step 2: Go to the “develop” branch & “Git-Case-Study-1” repository. You will notice that “feature.txt” has been successfully merged into the “develop” branch.
Step 3: Push all “master” branch changes to remote repository “Git-Case-Study-1” using the below-given command:
git push Git-Case-Study-1 master
Step 4: Go to the “master” branch in the “Git-Case-Study-1”, both the “develop.txt” & “feature.txt” files will be shown here now.
Now, the code will be in the “Release state”, you can do your “DevOps operation” now.
Check the Following DevOps Case Studies Here
Resolve Merge Conflict in The GitHub Repository — Git Case Study 2
Containerized an HTML Website using Docker on Production Environment — Docker Case Study
Creating an Architecture using Terraform on AWS — Terraform Case Study
Integration of DevOps Tools with Jenkins — Jenkins Case Study
How to Deploy a Sample Website on Kubernetes Using Ingress — Kubernetes Case Study