-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (72 loc) · 2.75 KB
/
github-actions.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
name: bookwoori CI/CD v3
on:
push:
branches: ["deploy"]
jobs:
build-and-deploy:
name: Build and Deploy Services
runs-on: ubuntu-latest
strategy:
matrix:
service: [core, auth, gateway, chat, notification]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
# Eureka 관련 설정 삭제
- name: Remove Eureka Dependencies
run: |
find . -name 'build.gradle' | while read -r file; do
sed -i '/spring-cloud-starter-netflix-eureka-client/d' "$file"
sed -i '/spring-cloud-starter-netflix-eureka-server/d' "$file"
done
find . -name 'application*.yml' | while read -r file; do
sed -i '/eureka:/,+3d' "$file"
done
- name: Make application-prod.yml
run: |
mkdir -p ./${{ matrix.service }}/src/main/resources
touch ./${{ matrix.service }}/src/main/resources/application.yml
echo "${{ secrets[format('APPLICATION_{0}', matrix.service)] }}" > ./${{ matrix.service }}/src/main/resources/application.yml
- name: create-json
id: create-json
uses: jsdaniell/[email protected]
with:
name: "firebase-adminsdk.json"
json: ${{ secrets.FIREBASE_ADMINSDK }}
dir: "./notification/src/main/resources"
- name: Build Service with Gradle
run: |
cd ./${{ matrix.service }}
chmod +x ./gradlew
./gradlew clean build -x test --no-daemon
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker Build and Push
uses: docker/build-push-action@v6
with:
context: ./${{ matrix.service }}
file: ./${{ matrix.service }}/Dockerfile
platforms: linux/arm64/v8
push: true
tags: ${{ secrets[format('DOCKER_REPO_{0}', matrix.service)] }}:v2
- name: Deploy to Server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
script: |
echo "${{ secrets.DOCKER_COMPOSE }}" | sudo tee ./docker-compose.yml
sudo docker ps -a --filter "name=app" --format "{{.ID}}" | xargs -r sudo docker stop
sudo docker ps -a --filter "name=app" --format "{{.ID}}" | xargs -r sudo docker rm -f
sudo docker stop auth-app
sudo docker pull ${{ secrets[format('DOCKER_REPO_{0}', matrix.service)] }}:v2
sudo docker-compose up -d