Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting: CD 파이프라인을 구축한다. #153

Merged
merged 3 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Deploy

on:
push:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{secrets.PRIVATE_TOKEN}}
submodules: true
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Make directory for deliver
run: mkdir deploy

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

- name: Deploy Prod use SCP
uses: appleboy/scp-action@master
with:
username: ubuntu
host: ${{ secrets.TICKETING_HOST }}
key: ${{ secrets.PRIVATE_KEY }}
source: "./build/libs/*.jar"
target: "/home/ubuntu/deploy"
strip_components: 2

- name: Run jar on EC2 using SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.TICKETING_HOST }}
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }}
script: |
PID=$(pgrep -f 'java -jar /home/ubuntu/deploy/*.jar')
if [ -n "$PID" ]; then
echo "Stopping existing application with PID $PID"
kill -9 $PID
fi
nohup java -jar /home/ubuntu/deploy/*.jar &

- name: Deploy Prod use SCP
uses: appleboy/scp-action@master
with:
username: ubuntu
host: ${{ secrets.WAITING_HOST }}
key: ${{ secrets.PRIVATE_KEY }}
source: "./build/libs/*.jar"
target: "/home/ubuntu/deploy"
strip_components: 2

- name: Run jar on EC2 using SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.WAITING_HOST }}
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }}
script: |
PID=$(pgrep -f 'java -jar /home/ubuntu/deploy/*.jar')
if [ -n "$PID" ]; then
echo "Stopping existing application with PID $PID"
kill -9 $PID
fi
nohup java -jar /home/ubuntu/deploy/*.jar &
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

개행 추가해주세요!

4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ java {
}
}

jar {
enabled = false
}

configurations {
asciidoctorExt
compileOnly {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.thirdparty.ticketing.global.infra;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ALBHealthCheckController {
@GetMapping("/health-check")
public ResponseEntity<Void> healthCheck() {
return ResponseEntity.ok().build();
}
}
Loading