-
Notifications
You must be signed in to change notification settings - Fork 1
73 lines (64 loc) · 2.17 KB
/
work.yml
File metadata and controls
73 lines (64 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: neobank CD
on:
push:
branches:
- 'main'
jobs:
build:
name: 이미지 빌드 및 도커허브 푸시
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: refs/heads/main
- name: application.yml 생성
run: |
mkdir -p src/main/resources
printf "%s" "${{ secrets.APPLICATION_YML }}" > src/main/resources/application.yml
- name: JDK 17 설치
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: ✨ Maven Caching
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-
- name: ✨ Jar 파일 빌드
run: mvn clean package -DskipTests
- name: ✨ DockerHub에 로그인
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: ✨ Docker Image 빌드 후 DockerHub에 Push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64
tags: ${{ secrets.DOCKER_REPO }}/neobank:latest
deploy:
name: 원격 서버에 배포
runs-on: ubuntu-latest
needs: build
steps:
- name: 원격 서버에 배포하기
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
port: 22
script: |
sudo docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} -p ${{ secrets.DOCKER_HUB_PASSWORD }}
sudo docker stop neobank_app || true
sudo docker rm neobank_app || true
sudo docker pull ${{ secrets.DOCKER_REPO }}/neobank
sudo docker run --name=neobank_app --restart unless-stopped \
-p 8080:8080 -e TZ=Asia/Seoul -d ${{ secrets.DOCKER_REPO }}/neobank
sudo docker image prune -f