Skip to content

Commit

Permalink
Update and rename gradle.yml to deploy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
yeopyeop-82 authored Sep 9, 2024
1 parent 05e7973 commit 740675c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 67 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/deploy.yml
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'
67 changes: 0 additions & 67 deletions .github/workflows/gradle.yml

This file was deleted.

0 comments on commit 740675c

Please sign in to comment.