Spring Boot - Continuous Integration Using GitHub Actions
Last Updated :
23 Jul, 2025
Let's say we have two or more developers who are merging code into a single repository. There can be issues in merging code from different developers. So the Continuous Integration tools help in solving not just that but many other things like:
- Run an automated build after successful merging (like build, test code coverage, etc.).
- We can also automate deployment after proper checks.
- Not just that, these platforms also provide a way to communicate with others with comments to let's say, solve a merging conflict or review a pull request.
- It also helps in running it on different OS.
One of the tools that we will be using here is GitHub Actions to accomplish our CI workflow. It is a powerful tool that can be utilized for continuous deployment as well.
Prerequisites:
- Keep IntelliJ Community(or related IDE)
- GitHub account
- JDK 11 and gitbash (or a related tool to push code)
Step-by-Step Implementation
Step 1: Let's create a basic Spring boot project first
a). Go to https://start.spring.io/
- Project: Maven | Language: Java | Spring Boot: 2.7.14
- Project Metadata:
- Group: com.example | Artifact: demo-springgithubactions | Name: demo-springgithubactions
- Description: Demo project for Spring Boot with GitHub actions
- Package name: com.example.demo-springgithubactions
- Packaging: Jar | Java: 11 | Dependencies: Spring Web
b). Open in IntelliJ. Run the following command in the terminal
./mvnw clean install
c). Create following folders (....\demo-springgithubactions\.github\workflows\build.yml) and file (build.yml) which will be detected and used by github to run workflows using github actions.

d). Update the file with following code
name: Build a JAR in spring boot using springboot
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: '11'
- name: Build with Maven
run: mvn clean install
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
with:
name: java-app
path: '${{ github.workspace }}/target/*.jar'
- name: Run Tests
run: mvn test
e). Create following folders (....\src\main\java\com\example\demospringgithubactions\controller\HelloWorld.java) and file (HelloWorld.java).

f). Update the file with following code.
Java
package com.example.demospringgithubactions.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloWorld {
@GetMapping
public String hello()
{
return "<!DOCTYPE html>\n"
+ "<html>\n"
+ "<head>\n"
+ "<style>\n"
+ "h1 {text-align: center;}\n"
+ "</style>\n"
+ "</head>\n"
+ "<body>\n"
+ "\n"
+ "<h1>Yaay!! you did it XD</h1>\n"
+ "\n"
+ "</body>\n"
+ "</html>\n";
}
}
g). Create following folders
(....\src\test\java\com\example\demospringgithubactions\DemoSpringgithubactionsApplicationTests.java) and file (DemoSpringgithubactionsApplicationTests.java).
h). Update the file with following code.
Java
package com.example.demospringgithubactions;
import static org.hamcrest.Matchers.containsString;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import com.example.demospringgithubactions.controller.HelloWorld;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
@RunWith(SpringRunner.class)
@WebMvcTest(HelloWorld.class)
class DemoSpringgithubactionsApplicationTests {
@Autowired
private MockMvc mockMvc;
@Test
public void checkSuccessMessage() throws Exception
{
this.mockMvc
.perform(get("/"))
.andExpect(status().isOk())
.andExpect(content().string(
containsString("Yaay!! you did it XD")));
}
}
i). Run the code and verify if you are able to hit "http://localhost:8080/" end point with message dispalyed "Yaay!! you did it XD".
Step 2: Let's push our code to GitHub
git init
git add -A
git commit -m 'Added my project'
git remote add origin <github-ssh-url>
git push -u -f origin main
Step 3: Go to Github actions tab and you will see the job running automatically

Similar Reads
Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance
10 min read
Spring Boot Interview Questions and Answers Spring Boot is a Java-based framework used to develop stand-alone, production-ready applications with minimal configuration. Introduced by Pivotal in 2014, it simplifies the development of Spring applications by offering embedded servers, auto-configuration, and fast startup. Many top companies, inc
15+ min read
Spring Tutorial Spring Framework is a comprehensive and versatile platform for enterprise Java development. It is known for its Inversion of Control (IoC) and Dependency Injection (DI) capabilities that simplify creating modular and testable applications. Key features include Spring MVC for web development, Spring
13 min read
Introduction to Spring Boot Spring is widely used for creating scalable applications. For web applications, Spring provides Spring MVC, a commonly used module for building robust web applications. The major drawback of traditional Spring projects is that configuration can be time-consuming and overwhelming for new developers.
5 min read
Spring Boot - Annotations Spring Boot Annotations are a form of metadata that provides data about a spring application. Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the
7 min read
Git Tutorial Git is an essential tool for developers, enabling them to manage and track project changes. Whether you're working on a solo project or collaborating with a team, Git keeps everything organized and under control. This Git Tutorial, from beginner to advanced, will give you a complete understanding of
13 min read
Best Way to Master Spring Boot â A Complete Roadmap In the corporate world, they say "Java is immortal!". But Why? Java remains one of the major platforms for developing enterprise applications. Enterprise Applications are used by large companies to make money. Those applications have high-reliability requirements and an enormous codebase. According
14 min read
Git Cheat Sheet The Git Cheat Sheet is a quick, well-organized guide designed for both beginners and experienced developers/DevOps engineers. It serves as a go-to reference for learning and recalling essential Git concepts and commands. In this Git Cheat Sheet, we have covered all the basics to advanced Git command
9 min read
Spring Boot - Architecture Spring Boot is built on top of the core Spring framework. It simplifies and automates Spring-based application development by reducing the need for manual configuration. Spring Boot follows a layered architecture, where each layer interacts with other layers in a hierarchical order. The official Spr
3 min read
Spring Boot 3.0 - JWT Authentication with Spring Security using MySQL Database In Spring Security 5.7.0, the Spring team deprecated the WebSecurityConfigurerAdapter, as they encourage users to move towards a component-based security configuration. Spring Boot 3.0 has come with many changes in Spring Security. In this article, we are going to learn how to implement JWT authenti
8 min read