Skip to content

[HOTFIX] 서버 이전을 하며 workflow 및 터널링 방식 변경 #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 29 additions & 22 deletions .github/workflows/boolock-dev-cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ name: dev ci/cd action

on:
push:
branches: ['main']
branches: ['dev']
pull_request:
branches: ['dev']
workflow_dispatch:

jobs:
build:
Expand Down Expand Up @@ -74,26 +77,30 @@ jobs:
DOCKERHUB_USERNAME=${{ secrets.DOCKERHUB_USERNAME }}
TYPE=test

deploy:
if: github.event_name == 'push'
needs: build
runs-on: ubuntu-latest
steps:
- name: Deploy with docker
uses: appleboy/ssh-action@v0.1.6
with:
host: ${{ secrets.TEST_SSH_HOST }}
username: ${{ secrets.TEST_SSH_USER }}
password: ${{ secrets.TEST_SSH_PASSWORD }}
port: ${{ secrets.TEST_SSH_PORT }}
script: |
cd boolock/refactor-web31-BooLock
git fetch origin
git checkout dev
git pull origin dev
## [NOTICE] 지금처럼 4대의 서버 유지가 어려워, main 서버 두개만 유지시킬 예정입니다.
## 당분간은 빌드 체크만 수행하도록 합니다.
## 리팩토링 작업 중 서버에 올려 실수행 과정을 체크할 필요가 있을 시 따로 말해주세요.

# deploy:
# if: github.event_name == 'push'
# needs: build
# runs-on: ubuntu-latest
# steps:
# - name: Deploy with docker
# uses: appleboy/ssh-action@v0.1.6
# with:
# host: ${{ secrets.TEST_SSH_HOST }}
# username: ${{ secrets.TEST_SSH_USER }}
# key: ${{ secrets.TEST_SSH_KEY }}
# port: ${{ secrets.TEST_SSH_PORT }}
# script: |
# cd boolock/refactor-web31-BooLock
# git fetch origin
# git checkout hotfix_250308
# git pull origin hotfix_250308

echo "DOCKERHUB_USERNAME=${{ secrets.DOCKERHUB_USERNAME }}" > .env
echo "${{ secrets.DOCKERHUB_ACCESS_TOKEN }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
# echo "DOCKERHUB_USERNAME=${{ secrets.DOCKERHUB_USERNAME }}" > .env
# echo "${{ secrets.DOCKERHUB_ACCESS_TOKEN }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin

sudo docker compose -f docker-compose.test.yml pull
sudo docker compose -f docker-compose.test.yml up -d --force-recreate --remove-orphans
# sudo docker compose -f docker-compose.yml pull
# sudo docker compose -f docker-compose.yml up -d --force-recreate --remove-orphans
14 changes: 5 additions & 9 deletions .github/workflows/boolock-main-cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,25 +85,21 @@ jobs:
needs: build
runs-on: ubuntu-latest
steps:
- name: Login to Docker Hub
run: |
echo "${{ secrets.DOCKERHUB_ACCESS_TOKEN }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin

- name: Deploy with docker
uses: appleboy/ssh-action@v0.1.6
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
password: ${{ secrets.SSH_PASSWORD }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
cd boolock/refactor-web31-BooLock
git fetch origin
git checkout main
git pull origin main
git checkout hotfix_250308
git pull origin hotfix_250308

echo "DOCKERHUB_USERNAME=${{ secrets.DOCKERHUB_USERNAME }}" > .env
echo "${{ secrets.DOCKERHUB_ACCESS_TOKEN }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin

sudo docker compose pull
sudo docker compose up -d --force-recreate --remove-orphans
sudo docker compose -f docker-compose.yml pull
sudo docker compose -f docker-compose.yml up -d --force-recreate --remove-orphans
4 changes: 2 additions & 2 deletions .github/workflows/check-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
branch_name=$(jq -r .pull_request.head.ref "$GITHUB_EVENT_PATH")
echo "Source Branch: $branch_name"

if [[ ! $branch_name =~ ^(feat/[0-9]+|bug/[0-9]+|refactor/[0-9]+|hotfix_[0-9]{4}|chore_[0-9]{4}|gh-pages)$ ]]; then
echo "Error: Branch name must follow the pattern 'feat/[number]', 'bug/[number]', 'hotfix_mmdd', 'chore_mmdd', or 'gh-pages'."
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
echo "Error: Branch name must follow the pattern 'feat/[number]', 'bug/[number]', 'hotfix_mmdd', 'hotfix_yymmdd', 'chore_mmdd', 'chore_yymmdd' or 'gh-pages'."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

새해를 맞이해 브랜치명도 수정해주시다니,,,역시 대현지님

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ㅋㅋㅋㅋㅋ action 통과를 못하더라고요ㅋㅋㅋ

exit 1
fi

Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ swagger-output.json
# Ignore Storybook build folder
storybook-static/

ssl/
ssl/

*.pem
3 changes: 2 additions & 1 deletion apps/server/src/config/dbConnection.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import mongoose from 'mongoose';
import 'dotenv/config';
import { createTunnel } from 'tunnel-ssh';
import fs from 'fs';

const setDbConnection = async () => {
const isLocal = process.env.IS_LOCAL === 'true';
Expand All @@ -14,7 +15,7 @@ const setDbConnection = async () => {
host: process.env.SSH_HOST,
port: process.env.SSH_PORT,
username: process.env.SSH_USER,
password: process.env.SSH_PASSWORD,
privateKey: fs.readFileSync('./pem/boolock-public-key.pem'),
};

const serverOptions = {
Expand Down