-
Notifications
You must be signed in to change notification settings - Fork 3
85 lines (72 loc) · 3.05 KB
/
baguni.test.ranking.deploy.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
name: Baguni Test Ranking-Module CI/CD
on:
push:
branches:
- 'be-develop' # 배포 대상 브랜치
paths:
- 'backend/baguni-core/**'
- 'backend/baguni-ranking/**'
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
env:
docker-hub-username: 'minkyeu'
docker-hub-repo: 'baguni' # TODO: change to baguni
module-name: 'baguni-ranking'
steps:
# 저장소 Checkout
- name: Checkout source code
uses: actions/checkout@v4
# Gradle 실행 권한 부여
- name: Grant execute permission to gradlew
run: chmod +x ./backend/gradlew
# JDK 설치
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'corretto'
# Spring boot application, Docker image 빌드
- name: Build and Deploy ${{ env.module-name }} Module
run: |
./backend/gradlew -p backend/${{ env.module-name }} clean build -x test
docker build -t ${{ env.docker-hub-username }}/${{ env.docker-hub-repo }}:${{ env.module-name }}-${{ github.sha }} backend/${{ env.module-name }}
- # Docker hub 로그인
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ env.docker-hub-username }}
password: ${{ secrets.DOCKERHUB_REPO_BAGUNI_TOKEN }}
- # Docker hub 업로드
name: Publish to docker hub
run: docker push ${{ env.docker-hub-username }}/${{ env.docker-hub-repo }}:${{ env.module-name }}-${{ github.sha }}
- name: Deploy on Test-Server
uses: appleboy/ssh-action@master
with:
host: minlife.me
port: 4242
username: root
password: ${{ secrets.SSH_TEST_SERVER_KYEU_PASSWORD }}
script: |
echo "login docker hub for private repository access ..."
echo ${{ secrets.DOCKERHUB_REPO_BAGUNI_TOKEN }} | docker login -u ${{ env.docker-hub-username }} --password-stdin
echo "docker - pulling..."
docker pull ${{ env.docker-hub-username }}/${{ env.docker-hub-repo }}:${{ env.module-name }}-${{ github.sha }}
echo "docker - changing image name and tag ..."
docker tag ${{ env.docker-hub-username }}/${{ env.docker-hub-repo }}:${{ env.module-name }}-${{ github.sha }} ${{ env.docker-hub-repo }}:${{ env.module-name }}-staging
echo "moving to project directory..."
cd /home/project/baguni/develop
echo "restarting container..."
docker compose down ${{ env.module-name }}
docker compose up ${{ env.module-name }} -d
- name: Discord Webhook Notification
uses: sarisia/[email protected]
if: always()
with:
webhook: ${{ secrets.DISCORD_WEBHOOK_URL }}
status: ${{ job.status }}
title: 'TEST RANKING SERVER DEPLOY'
color: 0xff91a4
url: 'https://github.com/sarisia/actions-status-discord'
username: GitHub Actions