Skip to content

Commit 7fdec15

Browse files
Nidhi GuptaNidhi Gupta
authored andcommitted
microservice code
1 parent a0a834f commit 7fdec15

File tree

5 files changed

+133
-3
lines changed

5 files changed

+133
-3
lines changed

.github/workflows/hello_build.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: "Hello Build and Terraform Deployment"
2+
on:
3+
# Manual trigger
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- 'microservices/HelloService/**'
10+
pull_request:
11+
branches: [ main ]
12+
paths:
13+
- 'HelloService/**'
14+
jobs:
15+
build:
16+
defaults:
17+
run:
18+
working-directory: ./microservices/HelloService
19+
name: Maven Build
20+
runs-on: [ ubuntu-latest ]
21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: Set up JDK 11
24+
uses: actions/setup-java@v2
25+
with:
26+
java-version: '11'
27+
distribution: 'adopt'
28+
- name: Build with Maven
29+
run: mvn package
30+
- name: Upload Artifact
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: app.jar
34+
path: microservices/HelloService/target/HelloService-1.jar
35+
- name: Configure AWS credentials
36+
uses: aws-actions/configure-aws-credentials@v1
37+
with:
38+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
39+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
40+
aws-region: us-east-1
41+
42+
- name: Login to Public ECR
43+
uses: docker/login-action@v1
44+
with:
45+
registry: public.ecr.aws
46+
47+
- name: Download Artifact
48+
uses: actions/download-artifact@v4
49+
with:
50+
name: app.jar
51+
52+
- name: Build, tag, and push image to Amazon ECR
53+
id: build-image
54+
env:
55+
ECR_REGISTRY: public.ecr.aws/w0f5g4k6
56+
ECR_REPOSITORY: hello-svc
57+
IMAGE_TAG: latest
58+
run: |
59+
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
60+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
61+
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
62+
63+
64+
65+

.github/workflows/world_build.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: "World Service Build and Push"
2+
on:
3+
# Manual trigger
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- 'microservices/WorldService/**'
10+
pull_request:
11+
branches: [ main ]
12+
paths:
13+
- 'WorldService/**'
14+
jobs:
15+
build:
16+
defaults:
17+
run:
18+
working-directory: ./microservices/WorldService
19+
name: Maven Build
20+
runs-on: [ ubuntu-latest ]
21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: Set up JDK 11
24+
uses: actions/setup-java@v2
25+
with:
26+
java-version: '11'
27+
distribution: 'adopt'
28+
- name: Build with Maven
29+
run: mvn package
30+
- name: Upload Artifact
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: app.jar
34+
path: microservices/WorldService/target/world-service-1.jar
35+
- name: Configure AWS credentials
36+
uses: aws-actions/configure-aws-credentials@v1
37+
with:
38+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
39+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
40+
aws-region: us-east-1
41+
42+
- name: Login to Public ECR
43+
uses: docker/login-action@v1
44+
with:
45+
registry: public.ecr.aws
46+
47+
- name: Download Artifact
48+
uses: actions/download-artifact@v4
49+
with:
50+
name: app.jar
51+
52+
- name: Build, tag, and push image to Amazon ECR
53+
id: build-image
54+
env:
55+
ECR_REGISTRY: public.ecr.aws/w0f5g4k6
56+
ECR_REPOSITORY: client-svc
57+
IMAGE_TAG: latest
58+
run: |
59+
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
60+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
61+
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
62+
63+
64+
65+

microservices/HelloService/src/main/java/helloservice/controllers/HelloController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class HelloController {
99
@GetMapping("/hello")
1010
public String getHello() {
1111

12-
return "Hello from hello Service \n";
12+
return "****Hello from hello Service****";
1313

1414
}
1515

microservices/HelloWorldClient/src/main/java/helloworldclient/controllers/HelloWorldController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ public class HelloWorldController {
2222
public String getHelloWorld() {
2323
String hello = rest.getForObject(helloServiceUrl + "/hello", String.class);
2424
String world = rest.getForObject(worldServiceUrl + "/world", String.class);
25-
return hello + " " + world;
25+
return hello + "*****" + world;
2626
}
2727
}

microservices/WorldService/src/main/java/worldservice/controllers/WorldController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class WorldController {
99
@GetMapping("/world")
1010
public String getWorld(){
1111

12-
return "hello from service World \n";
12+
return "/n ******Hello from service World********";
1313

1414
}
1515

0 commit comments

Comments
 (0)