-
Notifications
You must be signed in to change notification settings - Fork 2
78 lines (71 loc) · 2.51 KB
/
dev-publish.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
68
69
70
71
72
73
74
75
76
77
78
name: Deploy to EC2
on:
pull_request:
branches: ["develop"]
push:
branches: ["develop"]
jobs:
build_deploy_dev:
name: Build, Deploy to EC2
runs-on: ubuntu-latest
defaults:
run:
working-directory: "./emopic"
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
# - name: create-json
# id: create-json
# uses: jsdaniell/create-json@v1.2.2
# with:
# name: "key.json"
# json: ${{ secrets.GCS_KEY_JSON }}
# dir: "./emopic/src/main/resources/"
# 캐시 추가
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# gradlew 권한 변경
- name: Grant execute permission for gradlew
run: chmod +x gradlew
## gradle build
- name: Clean with Gradle
run: ./gradlew clean
## gradle build
- name: Build with Gradle
run: ./gradlew bootJar
# gradle 캐쉬 제거
- name: Cleanup Gradle Cache
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
if: ${{ always() }}
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
## 서버 이미지 빌드 및 도커허브에 push
- name: server docker build and push
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t ${{ secrets.DOCKER_IMAGE_NAME}} --platform linux/arm64 .
docker push ${{ secrets.DOCKER_IMAGE_NAME }}
## docker 이미지 다운로드 및 docker compose 명령어를 이용해 컨테아너 살행
- name: executing remote ssh commands using password
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DEV_HOST }}
username: ${{ secrets.DEV_USERNAME }}
key: ${{ secrets.DEV_SERVER_KEY }}
script: |
sudo docker rm -f $(docker ps -qa)
sudo docker pull ${{ secrets.DOCKER_IMAGE_NAME }}
docker compose up -d
docker image prune -f