-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update and rename gradle.yml to deploy.yml
- Loading branch information
1 parent
05e7973
commit 740675c
Showing
2 changed files
with
40 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: CI/CD for Spring Boot Application | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: '17' | ||
|
||
- name: Build with Maven | ||
run: mvn clean package | ||
|
||
- name: Build Docker image | ||
run: docker build -t your-dockerhub-username/spring-boot-app . | ||
|
||
- name: Log in to Docker Hub | ||
run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin | ||
|
||
- name: Push Docker image to Docker Hub | ||
run: docker push your-dockerhub-username/spring-boot-app | ||
|
||
deploy: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Deploy to EC2 | ||
run: | | ||
ssh -o StrictHostKeyChecking=no -i your-ec2-key.pem ubuntu@your-ec2-instance 'docker pull your-dockerhub-username/spring-boot-app && docker stop spring-app || true && docker rm spring-app || true && docker run -d -p 8080:8080 --name spring-app your-dockerhub-username/spring-boot-app' |
This file was deleted.
Oops, something went wrong.