Skip to content

Commit 1bc761c

Browse files
authored
[HOTFIX] 서버 이전을 하며 workflow 및 터널링 방식 변경 (#41)
* 🙀 chore: workflow ssh key로 셋팅하여 테스트 * 🔨 refactor: mongodb ssh터널링 연결할 때 password방식에서 pem 방식으로 변경 * 🙀 chore: check branch workflow hotfix 브랜치 양식 추가 * 🙀 chore: check branch 목록 추가 (chore_yymmdd) * 🙀 chore: main 및 dev workflow 스크립트 수정
1 parent 63dd116 commit 1bc761c

File tree

5 files changed

+41
-35
lines changed

5 files changed

+41
-35
lines changed

.github/workflows/boolock-dev-cicd.yml

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ name: dev ci/cd action
22

33
on:
44
push:
5-
branches: ['main']
5+
branches: ['dev']
6+
pull_request:
7+
branches: ['dev']
8+
workflow_dispatch:
69

710
jobs:
811
build:
@@ -74,26 +77,30 @@ jobs:
7477
DOCKERHUB_USERNAME=${{ secrets.DOCKERHUB_USERNAME }}
7578
TYPE=test
7679
77-
deploy:
78-
if: github.event_name == 'push'
79-
needs: build
80-
runs-on: ubuntu-latest
81-
steps:
82-
- name: Deploy with docker
83-
uses: appleboy/ssh-action@v0.1.6
84-
with:
85-
host: ${{ secrets.TEST_SSH_HOST }}
86-
username: ${{ secrets.TEST_SSH_USER }}
87-
password: ${{ secrets.TEST_SSH_PASSWORD }}
88-
port: ${{ secrets.TEST_SSH_PORT }}
89-
script: |
90-
cd boolock/refactor-web31-BooLock
91-
git fetch origin
92-
git checkout dev
93-
git pull origin dev
80+
## [NOTICE] 지금처럼 4대의 서버 유지가 어려워, main 서버 두개만 유지시킬 예정입니다.
81+
## 당분간은 빌드 체크만 수행하도록 합니다.
82+
## 리팩토링 작업 중 서버에 올려 실수행 과정을 체크할 필요가 있을 시 따로 말해주세요.
83+
84+
# deploy:
85+
# if: github.event_name == 'push'
86+
# needs: build
87+
# runs-on: ubuntu-latest
88+
# steps:
89+
# - name: Deploy with docker
90+
# uses: appleboy/ssh-action@v0.1.6
91+
# with:
92+
# host: ${{ secrets.TEST_SSH_HOST }}
93+
# username: ${{ secrets.TEST_SSH_USER }}
94+
# key: ${{ secrets.TEST_SSH_KEY }}
95+
# port: ${{ secrets.TEST_SSH_PORT }}
96+
# script: |
97+
# cd boolock/refactor-web31-BooLock
98+
# git fetch origin
99+
# git checkout hotfix_250308
100+
# git pull origin hotfix_250308
94101

95-
echo "DOCKERHUB_USERNAME=${{ secrets.DOCKERHUB_USERNAME }}" > .env
96-
echo "${{ secrets.DOCKERHUB_ACCESS_TOKEN }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
102+
# echo "DOCKERHUB_USERNAME=${{ secrets.DOCKERHUB_USERNAME }}" > .env
103+
# echo "${{ secrets.DOCKERHUB_ACCESS_TOKEN }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
97104

98-
sudo docker compose -f docker-compose.test.yml pull
99-
sudo docker compose -f docker-compose.test.yml up -d --force-recreate --remove-orphans
105+
# sudo docker compose -f docker-compose.yml pull
106+
# sudo docker compose -f docker-compose.yml up -d --force-recreate --remove-orphans

.github/workflows/boolock-main-cicd.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,25 +85,21 @@ jobs:
8585
needs: build
8686
runs-on: ubuntu-latest
8787
steps:
88-
- name: Login to Docker Hub
89-
run: |
90-
echo "${{ secrets.DOCKERHUB_ACCESS_TOKEN }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
91-
9288
- name: Deploy with docker
9389
uses: appleboy/ssh-action@v0.1.6
9490
with:
9591
host: ${{ secrets.SSH_HOST }}
9692
username: ${{ secrets.SSH_USER }}
97-
password: ${{ secrets.SSH_PASSWORD }}
93+
key: ${{ secrets.SSH_KEY }}
9894
port: ${{ secrets.SSH_PORT }}
9995
script: |
10096
cd boolock/refactor-web31-BooLock
10197
git fetch origin
102-
git checkout main
103-
git pull origin main
98+
git checkout hotfix_250308
99+
git pull origin hotfix_250308
104100
105101
echo "DOCKERHUB_USERNAME=${{ secrets.DOCKERHUB_USERNAME }}" > .env
106102
echo "${{ secrets.DOCKERHUB_ACCESS_TOKEN }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
107103
108-
sudo docker compose pull
109-
sudo docker compose up -d --force-recreate --remove-orphans
104+
sudo docker compose -f docker-compose.yml pull
105+
sudo docker compose -f docker-compose.yml up -d --force-recreate --remove-orphans

.github/workflows/check-branch.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ jobs:
1616
branch_name=$(jq -r .pull_request.head.ref "$GITHUB_EVENT_PATH")
1717
echo "Source Branch: $branch_name"
1818
19-
if [[ ! $branch_name =~ ^(feat/[0-9]+|bug/[0-9]+|refactor/[0-9]+|hotfix_[0-9]{4}|chore_[0-9]{4}|gh-pages)$ ]]; then
20-
echo "Error: Branch name must follow the pattern 'feat/[number]', 'bug/[number]', 'hotfix_mmdd', 'chore_mmdd', or 'gh-pages'."
19+
if [[ ! $branch_name =~ ^(feat/[0-9]+|bug/[0-9]+|refactor/[0-9]+|hotfix_[0-9]{4}|hotfix_[0-9]{6}|chore_[0-9]{4}|chore_[0-9]{6}|gh-pages)$ ]]; then
20+
echo "Error: Branch name must follow the pattern 'feat/[number]', 'bug/[number]', 'hotfix_mmdd', 'hotfix_yymmdd', 'chore_mmdd', 'chore_yymmdd' or 'gh-pages'."
2121
exit 1
2222
fi
2323

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,6 @@ swagger-output.json
4343
# Ignore Storybook build folder
4444
storybook-static/
4545

46-
ssl/
46+
ssl/
47+
48+
*.pem

apps/server/src/config/dbConnection.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import mongoose from 'mongoose';
22
import 'dotenv/config';
33
import { createTunnel } from 'tunnel-ssh';
4+
import fs from 'fs';
45

56
const setDbConnection = async () => {
67
const isLocal = process.env.IS_LOCAL === 'true';
@@ -14,7 +15,7 @@ const setDbConnection = async () => {
1415
host: process.env.SSH_HOST,
1516
port: process.env.SSH_PORT,
1617
username: process.env.SSH_USER,
17-
password: process.env.SSH_PASSWORD,
18+
privateKey: fs.readFileSync('./pem/boolock-public-key.pem'),
1819
};
1920

2021
const serverOptions = {

0 commit comments

Comments
 (0)