@@ -3,7 +3,7 @@ name: Spring Boot CI/CD
3
3
on :
4
4
push :
5
5
branches : [ main ]
6
- paths : [ 'backend/**' ] # Trigger only when backend files change
6
+ paths : [ 'backend/bookTable/ **' ] # Trigger only when backend files change
7
7
8
8
jobs :
9
9
build-test-coverage :
@@ -21,34 +21,70 @@ jobs:
21
21
22
22
- name : Grant Gradle Wrapper Permissions
23
23
run : chmod +x ./gradlew
24
- working-directory : ./backend
24
+ working-directory : ./backend/bookTable
25
25
26
26
- name : Build, Test, and Check Coverage
27
27
run : ./gradlew clean build test jacocoTestReport jacocoTestCoverageVerification
28
- working-directory : ./backend
28
+ working-directory : ./backend/bookTable
29
29
30
30
- name : Upload Coverage Report
31
31
uses : actions/upload-artifact@v3
32
32
with :
33
33
name : jacoco-coverage-report
34
- path : backend/build/reports/jacoco/test/html/
34
+ path : backend/bookTable/ build/reports/jacoco/test/html/
35
35
36
36
- name : Upload JAR Artifact
37
37
uses : actions/upload-artifact@v3
38
38
with :
39
39
name : spring-boot-jar
40
- path : backend/build/libs/*.jar
41
-
42
- # Uncomment and configure when ready for AWS deployment
43
- # deploy-to-aws:
44
- # needs: build-test-coverage
45
- # runs-on: ubuntu-latest
46
- # steps:
47
- # - name: Configure AWS Credentials
48
- # uses: aws-actions/configure-aws-credentials@v4
49
- # with:
50
- # aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
51
- # aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
52
- # aws-region: us-east-1
53
- # - name: Deploy to AWS
54
- # run: echo "Add your deployment commands here"
40
+ path : backend/bookTable/build/libs/*.jar
41
+
42
+ deploy-to-aws :
43
+ needs : build-test-coverage
44
+ runs-on : ubuntu-latest
45
+ steps :
46
+ - name : Checkout Code
47
+ uses : actions/checkout@v4
48
+
49
+ - name : Set Up Java 17
50
+ uses : actions/setup-java@v4
51
+ with :
52
+ java-version : 17
53
+ distribution : temurin
54
+
55
+ - name : Download JAR Artifact
56
+ uses : actions/download-artifact@v3
57
+ with :
58
+ name : spring-boot-jar
59
+ path : backend/bookTable/build/libs/
60
+
61
+ - name : Set Up Docker Buildx
62
+ uses : docker/setup-buildx-action@v2
63
+
64
+ - name : Configure AWS Credentials
65
+ uses : aws-actions/configure-aws-credentials@v4
66
+ with :
67
+ aws-access-key-id : ${{ secrets.AWS_ACCESS_KEY_ID }}
68
+ aws-secret-access-key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
69
+ aws-region : us-west-1
70
+
71
+ - name : Login to Amazon ECR
72
+ run : |
73
+ aws ecr get-login-password --region us-west-1 | docker login --username AWS --password-stdin 061039807046.dkr.ecr.us-west-1.amazonaws.com
74
+
75
+ - name : Build, Tag, and Push to ECR
76
+ working-directory : ./backend/bookTable
77
+ run : |
78
+ docker build -t booktable-app .
79
+ docker tag booktable-app:latest 061039807046.dkr.ecr.us-west-1.amazonaws.com/booktable-app:latest
80
+ docker push 061039807046.dkr.ecr.us-west-1.amazonaws.com/booktable-app:latest
81
+
82
+ - name : Install EB CLI
83
+ run : pip install awsebcli --upgrade
84
+
85
+ - name : Deploy to Elastic Beanstalk
86
+ working-directory : ./backend/bookTable
87
+ run : |
88
+ echo '{"AWSEBDockerrunVersion": "1", "Image": {"Name": "061039807046.dkr.ecr.us-west-1.amazonaws.com/booktable-app:latest", "Update": "true"}, "Ports": [{"ContainerPort": 8080, "HostPort": 80}]}' > Dockerrun.aws.json
89
+ zip -r app.zip Dockerrun.aws.json
90
+ eb deploy booktable-app-env
0 commit comments