How to Setup CI/CD for Your Project Using Github Actions | by Manoj Ahirwar | May, 2022


Picture by Mike Benna on Unsplash

On this article, I’ll present you how one can arrange your CI/CD deployment pipeline in straightforward steps. I’ll deploy my Spring boot mission on AWS elastic beanstalk. I’m not utilizing any Dockerization for my software.

Begin by creating a brand new listing known as .github . GitHub will robotically detect all of the .yml information inside this listing if you find yourself pushing your code to the GitHub repo.

Create a brand new file workflow-dev.yml

On this file, we shall be writing our directions for our CI/CD pipeline

What will we need to have in our CI/CI pipeline?

Job 1: Construct the code so we don’t have any compilation errors

Job 2: Generate a jar file of your code which shall be uploaded to your elastic beanstalk occasion

Job 3: Obtain the jar and add it to elastic beanstalk

Job 4: take away the artifact jar from the GitHub storage as soon as the deployment of the jar is completed.

we’ll begin the yml code with the under code.

We’re giving the identify of our pipeline. subsequent, we’re defining on what situations this workflow will run. if you happen to see we’re utilizing push and pull_request situations on the grasp department. meaning when somebody is pushing the code to the grasp department or if somebody is making a pull request in opposition to the grasp department, this workflow will run.

Subsequent, we’ll outline our Job 1 which is constructing the code.

In case your code is utilizing any non-public libs that require some credentials in your settings.xml in your maven mission. you may create these values within the GitHub secret on your repo and entry these values whereas constructing the code.

Subsequent is producing the artifact jar

The above step will run solely if you find yourself pushing the code to grasp as a result of when creating pull_request you don’t need to generate the jar. The above code can even add the generated artifact to the GitHub storage.

Now we need to obtain the jar and deploy it to the elastic beanstalk occasion.

When you see carefully, we’re utilizing a GitHub motion plugin known as einaregilsson/beanstalk-deploy@v13 and this makes use of some params which might be outlined by us. right here we might want to set some details about our elastic beanstalk occasion corresponding to software identify, env identify, area, and so forth and you may add your AWS entry and secret keys to GitHub secret and entry it in your pipeline.

the final step is to delete the artifact as soon as your code is deployed

Above will delete the jar from GitHub storage.

Right here is the complete code on your CI/CD pipeline.

Hope this text helps you arrange your CI/CD pipeline shortly so you may give attention to constructing.


More Posts