-
Notifications
You must be signed in to change notification settings - Fork 2
140 lines (113 loc) · 5.47 KB
/
notification-ci-cd.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: NotificationService CI/CD by jar
on:
push:
branches:
- 'notification/dev'
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Cache Gradle dependencies
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: chmod +x src/notification-service/gradlew
- name: 프로젝트 빌드
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
AUTH_JWT_SECRET_KEY: ${{ secrets.AUTH_JWT_SECRET_KEY }}
AUTH_MAIL_HOST: ${{ secrets.AUTH_MAIL_HOST }}
AUTH_MAIL_PASSWORD: ${{ secrets.AUTH_MAIL_PASSWORD }}
AUTH_MAIL_PORT: ${{ secrets.AUTH_MAIL_PORT }}
AUTH_MAIL_USERNAME: ${{ secrets.AUTH_MAIL_USERNAME }}
AUTH_REDIS_HOST: ${{ secrets.AUTH_REDIS_HOST }}
AUTH_REDIS_PORT: ${{ secrets.AUTH_REDIS_PORT }}
USER_DB_URI: ${{ secrets.USER_DB_URI }}
USER_DB_USERNAME: ${{ secrets.USER_DB_USERNAME }}
USER_DB_USER_DB_PASSWORD: ${{ secrets.USER_DB_USER_DB_PASSWORD }}
SOCIAL_DB_URI: ${{ secrets.SOCIAL_DB_URI }}
SOCIAL_DB_USERNAME: ${{ secrets.SOCIAL_DB_USERNAME }}
SOCIAL_DB_PASSWORD: ${{ secrets.SOCIAL_DB_PASSWORD }}
TIMELINE_REDIS_HOST: ${{ secrets.TIMELINE_REDIS_HOST }}
TIMELINE_REDIS_PORT: ${{ secrets.TIMELINE_REDIS_PORT }}
TIMELINE_REDIS_PASSWORD: ${{ secrets.TIMELINE_REDIS_PASSWORD }}
NOTIFICATOIN_DB_URI: ${{ secrets.NOTIFICATOIN_DB_URI }}
NOTIFICATOIN_DB_USERNAME: ${{ secrets.NOTIFICATOIN_DB_USERNAME }}
NOTIFICATOIN_DB_USER_DB_PASSWORD: ${{ secrets.NOTIFICATOIN_DB_USER_DB_PASSWORD }}
LIGHTSAIL_HOST: ${{ secrets.LIGHTSAIL_HOST }}
LIGHTSAIL_KEY: ${{ secrets.LIGHTSAIL_KEY }}
LIGHTSAIL_USERNAME: ${{ secrets.LIGHTSAIL_USERNAME }}
PASSPORT_KEY: ${{ secrets.PASSPORT_KEY }}
PASSPORT_ALGORITHM: ${{ secrets.PASSPORT_ALGORITHM }}
KAFKA_SERVERS: ${{ secrets.KAFKA_SERVERS }}
working-directory: ./src/search-service
run: ./gradlew clean build -x test
shell: bash
- name: API 빌드 파일 복사
uses: appleboy/scp-action@master
with:
host: ${{ secrets.LIGHTSAIL_HOST }}
username: ${{ secrets.LIGHTSAIL_USERNAME }}
key: ${{ secrets.LIGHTSAIL_KEY }}
source: "src/notification-service/build/libs/easel-notification-service-0.0.1-SNAPSHOT.jar"
target: "/home/ubuntu/palette/notification-service"
- name: API LIGHTSAIL 인스턴스 접속 및 애플리케이션 실행
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.LIGHTSAIL_HOST }}
username: ${{ secrets.LIGHTSAIL_USERNAME }}
key: ${{ secrets.LIGHTSAIL_KEY }}
script: |
sudo cd /home/ubuntu/palette/notification-service
sudo fuser -k 10009/tcp
sudo ./operate.sh
- name: Build and Push Docker Image
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
AUTH_JWT_SECRET_KEY: ${{ secrets.AUTH_JWT_SECRET_KEY }}
AUTH_MAIL_HOST: ${{ secrets.AUTH_MAIL_HOST }}
AUTH_MAIL_PASSWORD: ${{ secrets.AUTH_MAIL_PASSWORD }}
AUTH_MAIL_PORT: ${{ secrets.AUTH_MAIL_PORT }}
AUTH_MAIL_USERNAME: ${{ secrets.AUTH_MAIL_USERNAME }}
AUTH_REDIS_HOST: ${{ secrets.AUTH_REDIS_HOST }}
AUTH_REDIS_PORT: ${{ secrets.AUTH_REDIS_PORT }}
USER_DB_URI: ${{ secrets.USER_DB_URI }}
USER_DB_USERNAME: ${{ secrets.USER_DB_USERNAME }}
USER_DB_USER_DB_PASSWORD: ${{ secrets.USER_DB_USER_DB_PASSWORD }}
SOCIAL_DB_URI: ${{ secrets.SOCIAL_DB_URI }}
SOCIAL_DB_USERNAME: ${{ secrets.SOCIAL_DB_USERNAME }}
SOCIAL_DB_PASSWORD: ${{ secrets.SOCIAL_DB_PASSWORD }}
TIMELINE_REDIS_HOST: ${{ secrets.TIMELINE_REDIS_HOST }}
TIMELINE_REDIS_PORT: ${{ secrets.TIMELINE_REDIS_PORT }}
TIMELINE_REDIS_PASSWORD: ${{ secrets.TIMELINE_REDIS_PASSWORD }}
NOTIFICATOIN_DB_URI: ${{ secrets.NOTIFICATOIN_DB_URI }}
NOTIFICATOIN_DB_USERNAME: ${{ secrets.NOTIFICATOIN_DB_USERNAME }}
NOTIFICATOIN_DB_USER_DB_PASSWORD: ${{ secrets.NOTIFICATOIN_DB_USER_DB_PASSWORD }}
LIGHTSAIL_HOST: ${{ secrets.LIGHTSAIL_HOST }}
LIGHTSAIL_KEY: ${{ secrets.LIGHTSAIL_KEY }}
LIGHTSAIL_USERNAME: ${{ secrets.LIGHTSAIL_USERNAME }}
PASSPORT_KEY: ${{ secrets.PASSPORT_KEY }}
PASSPORT_ALGORITHM: ${{ secrets.PASSPORT_ALGORITHM }}
KAFKA_SERVERS: ${{ secrets.KAFKA_SERVERS }}
run: |
cd src/notification-service
./gradlew clean build -x test
docker run --privileged --rm tonistiigi/binfmt --install all
docker buildx create --use
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
docker buildx build --platform=linux/amd64,linux/arm64 -t $DOCKER_USERNAME/notification-service:latest . --push