Skip to content

Commit f6e253f

Browse files
Added a github docker build ci-cd file
1 parent 97792eb commit f6e253f

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

demo/.github/workflows/ci-cd.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# This workflow will build docker image and push it to DockerHub,
2+
# After that, This wrkflow build and push a new container image to Amazon ECR,
3+
# and then will deploy a new task definition to Amazon ECS, when there is a push to the "main" branch.
4+
5+
name: CI/CD Pipeline # Name of the CI/CD Pipeline
6+
7+
on:
8+
push:
9+
branches: [ "main" ] # Trigger on push events to the main branch
10+
pull_request:
11+
branches: [ "main" ] # Trigger on pull requests to the main branch
12+
13+
jobs:
14+
build-and-deploy:
15+
runs-on: ubuntu-latest # Runs on the latest version of Ubuntu | Default operating system environment for workflows unless explicitly specified.
16+
17+
steps:
18+
- name: Checkout code # Step to checkout the code from the repository | Fetch the source code repository into the runner machine where our workflow is executing.
19+
uses: actions/checkout@v4
20+
21+
- name: Set up JDK 17 # Step to set up JDK 17
22+
uses: actions/setup-java@v3
23+
with:
24+
java-version: '17'
25+
distribution: 'temurin'
26+
cache: maven
27+
28+
- name: Build with Maven # Step to build the project with Maven
29+
run: mvn clean install
30+
31+
- name: build and push the docker image to dockerhub
32+
run: |
33+
# 1. Login to DockerHub
34+
# 2. Build the Docker image
35+
# 3. Push the Docker image to DockerHub
36+
docker login -u gowthamdineshrajkumar -p gowthamdineshrajkumar
37+
docker build -t gowthamdineshrajkumar/demospringboot .
38+
docker push gowthamdineshrajkumar/demospringboot:latest

demo/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@
4848
<scope>runtime</scope>
4949
<optional>true</optional>
5050
</dependency>
51+
<dependency>
52+
<groupId>org.projectlombok</groupId>
53+
<artifactId>lombok</artifactId>
54+
<optional>true</optional>
55+
</dependency>
5156
<dependency>
5257
<groupId>org.springframework.boot</groupId>
5358
<artifactId>spring-boot-starter-test</artifactId>

0 commit comments

Comments
 (0)