Skip to content

Commit

Permalink
Merge pull request #77 from hyosung-second-team1/74-infra-자동-배포
Browse files Browse the repository at this point in the history
[Infra] 자동 배포
  • Loading branch information
dtd1614 authored May 14, 2024
2 parents 0179398 + 39f3a8d commit 797a593
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 5 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: deploy

on:
push:
branches:
- main

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: checkout
uses: actions/checkout@master

- name: create secure file
run: |
cd src/main/resources
touch secure.properties
echo "${{ secrets.SECURE }}" >> secure.properties
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew clean build --stacktrace

- name: Transfer WAR file to EC2
uses: appleboy/scp-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_KEY }}
port: ${{ secrets.EC2_SSH_PORT }}
source: "build/libs/meevote-0.0.1-SNAPSHOT.war"
target: "/home/ubuntu"

- name: SSH into EC2 and deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_KEY }}
port: ${{ secrets.EC2_SSH_PORT }}
script: |
sudo fuser -k 80/tcp
cd /home/ubuntu/build/libs
sudo nohup java -jar -Dspring.profiles.active=prod -Duser.timezone="Asia/Seoul" meevote-0.0.1-SNAPSHOT.war > app.log 2>&1 &
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id 'java'
id 'org.springframework.boot' version '3.1.11'
id 'io.spring.dependency-management' version '1.1.4'
id 'war'
}

group = 'today.meevote'
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
server:
port: 8081
spring:
datasource:
driver-class-name: oracle.jdbc.OracleDriver
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
server:
port: 80
spring:
datasource:
driver-class-name: oracle.jdbc.OracleDriver
url: ${datasource.url}
username: ${datasource.username}
password: ${datasource.password}
password: ${datasource.password}
1 change: 0 additions & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
server:
port: 8081
servlet:
jsp:
init-parameters:
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/today/meevote/MeevoteApplicationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
@SpringBootTest
class MeevoteApplicationTests {

@Test
void contextLoads() {
}
// @Test
// void contextLoads() {
// }

}

0 comments on commit 797a593

Please sign in to comment.