-
Notifications
You must be signed in to change notification settings - Fork 1
67 lines (60 loc) · 2.03 KB
/
ci.yml
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
name: Java CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest #ubuntu-20.04
steps:
# JDK version 설정
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
# Git pull
- name: Git pull
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.REMOTE_IP }}
username: ubuntu
key: ${{ secrets.REMOTE_PRIVATE_KEY }}
script: |
cd ../../var/www/Backend/
sudo git pull origin main
# Gradle build
- name: Build with Gradle
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.REMOTE_IP }}
username: ubuntu
key: ${{ secrets.REMOTE_PRIVATE_KEY }}
script: |
cd ../../var/www/Backend/
sudo ./gradlew build
# Spring 어플리케이션 Docker Image 빌드
- name: Build Docker Image For Spring
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.REMOTE_IP }}
username: ubuntu
key: ${{ secrets.REMOTE_PRIVATE_KEY }}
script: |
cd
sudo docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
sudo docker build -t ${{ secrets.DOCKER_USERNAME }}/connect_x .
sudo docker push ${{ secrets.DOCKER_USERNAME }}/connect_x
# 서버에서 Docker 이미지 실행
- name: EC2 Docker Run
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.REMOTE_IP }}
username: ubuntu
key: ${{ secrets.REMOTE_PRIVATE_KEY }}
script: |
sudo docker rm -f $(docker ps -qa)
sudo docker rmi ${{ secrets.DOCKER_USERNAME }}/connect_x
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/connect_x:latest
docker run -i -p 8080:8080 ${{ secrets.DOCKER_USERNAME }}/connect_x &