Skip to content
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

Merge dev into main #536

Merged
merged 15 commits into from
Jan 22, 2024
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
44 changes: 27 additions & 17 deletions .github/workflows/deploy-development.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Deploy development server to ec2

on:
Expand All @@ -9,28 +6,41 @@ on:
- dev

jobs:
build:
runs-on: self-hosted
deploy:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
defaults:
run:
working-directory: ${{ env.SERVER_PROFILE }}

steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0
with:
path: ${{ env.SERVER_PROFILE }}
- name: Checkout Repository
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 #v.3.5.1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: cp ~/config-injection/ecosystem-${{ env.SERVER_PROFILE }}.json ${{ env.PROJECT_PATH }}/ecosystem.json
- run: cp ~/config-injection/envs/.env.${{ env.NODE_ENV }} ${{ env.PROJECT_PATH }}/.env
- run: bash ${{ env.PROJECT_PATH }}/script/prebuild.sh
- run: sh ${{ env.PROJECT_PATH }}/script/reload.sh

- name: Deploy to EC2 using SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
script: |
cp ~/config-injection/ecosystem-${{ env.SERVER_PROFILE }}.json ${{ env.PROJECT_PATH }}/ecosystem.json &&
cp ~/config-injection/envs/.env.${{ env.NODE_ENV }} ${{ env.PROJECT_PATH }}/.env &&
cd ${{ env.PROJECT_PATH }} &&
git fetch --all &&
git checkout ${{ env.BRANCH_NAME }} &&
git pull origin ${{ env.BRANCH_NAME }} &&
bash script/prebuild.sh &&
bash script/reload.sh

env:
BRANCH_NAME: dev
NODE_ENV: development
SERVER_PROFILE: development
PROJECT_PATH: ~/actions-runner/_work/A.fume.Server/A.fume.Server/development
44 changes: 27 additions & 17 deletions .github/workflows/deploy-production-1.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Deploy production-1 server to ec2

on:
Expand All @@ -10,28 +7,41 @@ on:
- production-1

jobs:
build:
runs-on: self-hosted
deploy:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
defaults:
run:
working-directory: ${{ env.SERVER_PROFILE }}

steps:
- uses: actions/checkout@v2
with:
path: ${{ env.SERVER_PROFILE }}
- name: Checkout Repository
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: cp ~/config-injection/ecosystem-${{ env.SERVER_PROFILE }}.json ${{ env.PROJECT_PATH }}/ecosystem.json
- run: cp ~/config-injection/envs/.env.${{ env.NODE_ENV }} ${{ env.PROJECT_PATH }}/.env
- run: bash ${{ env.PROJECT_PATH }}/script/prebuild.sh
- run: sh ${{ env.PROJECT_PATH }}/script/reload.sh

- name: Deploy to EC2 using SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
script: |
cp ~/config-injection/ecosystem-${{ env.SERVER_PROFILE }}.json ${{ env.PROJECT_PATH }}/ecosystem.json &&
cp ~/config-injection/envs/.env.${{ env.NODE_ENV }} ${{ env.PROJECT_PATH }}/.env &&
cd ${{ env.PROJECT_PATH }} &&
git fetch --all &&
git checkout ${{ env.BRANCH_NAME }} &&
git pull origin ${{ env.BRANCH_NAME }} &&
bash script/prebuild.sh &&
bash script/reload.sh

env:
BRANCH_NAME: production-1
NODE_ENV: production
SERVER_PROFILE: production-1
PROJECT_PATH: ~/actions-runner/_work/A.fume.Server/A.fume.Server/production-1
44 changes: 27 additions & 17 deletions .github/workflows/deploy-production-2.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Deploy production-2 server to ec2

on:
Expand All @@ -10,28 +7,41 @@ on:
- production-2

jobs:
build:
runs-on: self-hosted
deploy:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
defaults:
run:
working-directory: ${{ env.SERVER_PROFILE }}

steps:
- uses: actions/checkout@v2
with:
path: ${{ env.SERVER_PROFILE }}
- name: Checkout Repository
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: cp ~/config-injection/ecosystem-${{ env.SERVER_PROFILE }}.json ${{ env.PROJECT_PATH }}/ecosystem.json
- run: cp ~/config-injection/envs/.env.${{ env.NODE_ENV }} ${{ env.PROJECT_PATH }}/.env
- run: bash ${{ env.PROJECT_PATH }}/script/prebuild.sh
- run: sh ${{ env.PROJECT_PATH }}/script/reload.sh

- name: Deploy to EC2 using SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
script: |
cp ~/config-injection/ecosystem-${{ env.SERVER_PROFILE }}.json ${{ env.PROJECT_PATH }}/ecosystem.json &&
cp ~/config-injection/envs/.env.${{ env.NODE_ENV }} ${{ env.PROJECT_PATH }}/.env &&
cd ${{ env.PROJECT_PATH }} &&
git fetch --all &&
git checkout ${{ env.BRANCH_NAME }} &&
git pull origin ${{ env.BRANCH_NAME }} &&
bash script/prebuild.sh &&
bash script/reload.sh

env:
BRANCH_NAME: production-2
NODE_ENV: production
SERVER_PROFILE: production-2
PROJECT_PATH: ~/actions-runner/_work/A.fume.Server/A.fume.Server/production-2
45 changes: 28 additions & 17 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,47 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Deploy production server to ec2

on:
workflow_dispatch:
push:
branches:
- main

jobs:
build:
runs-on: self-hosted
deploy:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
defaults:
run:
working-directory: ${{ env.SERVER_PROFILE }}

steps:
- uses: actions/checkout@v2
with:
path: ${{ env.SERVER_PROFILE }}
- name: Checkout Repository
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: cp ~/config-injection/ecosystem-${{ env.SERVER_PROFILE }}.json ${{ env.PROJECT_PATH }}/ecosystem.json
- run: cp ~/config-injection/envs/.env.${{ env.NODE_ENV }} ${{ env.PROJECT_PATH }}/.env
- run: bash ${{ env.PROJECT_PATH }}/script/prebuild.sh
- run: sh ${{ env.PROJECT_PATH }}/script/reload.sh

- name: Deploy to EC2 using SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
script: |
cp ~/config-injection/ecosystem-${{ env.SERVER_PROFILE }}.json ${{ env.PROJECT_PATH }}/ecosystem.json &&
cp ~/config-injection/envs/.env.${{ env.NODE_ENV }} ${{ env.PROJECT_PATH }}/.env &&
cd ${{ env.PROJECT_PATH }} &&
git fetch --all &&
git checkout ${{ env.BRANCH_NAME }} &&
git pull origin ${{ env.BRANCH_NAME }} &&
bash script/prebuild.sh &&
bash script/reload.sh

env:
BRANCH_NAME: main
NODE_ENV: production
SERVER_PROFILE: production
PROJECT_PATH: ~/actions-runner/_work/A.fume.Server/A.fume.Server/production
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Scents Node Server

- [기여하기](./docs/contribution.md)

- [환경, 배포](./docs/environments.md)

# 연관 프로젝트

[A.fume.Analysis](https://github.com/Scents-Note/A.fume.Analysis)
Expand Down
21 changes: 21 additions & 0 deletions docs/environments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 환경

- dev
- 목적: 개발환경에서 사용.
- 기준 브랜치: dev
- production-1
- 목적: ios 용 엔드포인트
- production-2
- 목적: android 용 엔드포인트

* production 이 현재 1과 2, 2개가 공존하는 상황. 초기에 안전성을 위해 분리한 것으로 보이나, 불필요한 분리여서 합치는 것이 좋다고 판단.

# 배포

- dev 환경
- dev 브랜치에 병합시 자동으로 배포됨
- production-1, production-2
- [저장소의 깃헙액션 페이지](https://github.com/Scents-Note/A.fume.Server/actions) 에서 각 환경에 해당하는 워크플로우 진입 후, 아래 과정을 따라 수행
- Run workflow 드랍다운 클릭
- 배포를 원하는 브랜치 선택
- 초록색 Run workflow 버튼 클릭
Loading
Loading