-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# 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://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs | ||
|
||
name: nest_lm CI | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
|
||
env: | ||
PROJECT_NAME: local_mingle | ||
BUCKET_NAME: s3-bucket-local-mingle | ||
CODE_DEPLOY_APP_NAME: CD-app-local-mingle | ||
DEPLOYMENT_GROUP_NAME: CD-app-group-local-mingle | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [18.x] | ||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'npm' | ||
- run: npm ci | ||
- run: npm run build --if-present | ||
|
||
# S3로 보낼 압축 파일 생성 | ||
- name: zip file | ||
run: | | ||
# zip으로 압축파일 생성 | ||
# CI.zip은 압축 파일 이름, 나머지는 압축할 코드 파일 또는 폴더를 지정합니다. | ||
# workflow와 동일한 위치의 폴더와 파일을 압축합니다. | ||
zip -qq -r ./$GITHUB_SHA.zip . | ||
# AWS 인증하기 | ||
- name: AWS configure credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
# 엑세스 키 입력 | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
# 엑세스 시크릿 키 입력 | ||
aws-secret-access-key: ${{ secrets.AWS_PRIVATE_ACCESS_KEY }} | ||
# 지역 설정: 서울 | ||
aws-region: ap-northeast-2 | ||
|
||
# S3로 업로드하기 | ||
- name: upload to S3 | ||
run: aws s3 cp ./$GITHUB_SHA.zip s3://s3-bucket-local-mingle/local_mingle/$GITHUB_SHA.zip | ||
|
||
# codeDeploy 실행 | ||
- name: request deploy to codedeploy | ||
run: aws deploy create-deployment | ||
--application-name CD-app-local-mingle | ||
--deployment-config-name CodeDeployDefault.AllAtOnce | ||
--deployment-group-name CD-app-group-local-mingle | ||
--s3-location bucket=s3-bucket-local-mingle,bundleType=zip,key=local_mingle/$GITHUB_SHA.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
version: 0.0 | ||
os: linux | ||
|
||
# S3로부터 받은 .zip file의 압축해제 경로 설정 | ||
files: | ||
- source: / | ||
destination: /home/ubuntu/LocalMingle-BE | ||
overwrite: yes | ||
file_exists_behavior: OVERWRITE | ||
|
||
# 압축해제 된 파일들의 권한 설정 | ||
permissions: | ||
- object: /home/ubuntu/LocalMingle-BE | ||
owner: ubuntu | ||
group: ubuntu | ||
|
||
# codedeploy가 참조할 스크립트의 경로 설정 | ||
hooks: | ||
AfterInstall: | ||
- location: scripts/deploy.sh | ||
timeout: 60 | ||
runas: ubuntu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# 프로젝트 위치 설정 | ||
REPOSITORY=/home/ubuntu/LocalMingle-BE | ||
|
||
# 프로젝트 위치로 이동 | ||
cd $REPOSITORY | ||
|
||
# 의존성 설치 | ||
echo "> install dependency" | ||
npm install | ||
|
||
# 프로젝트 build | ||
echo "> build application" | ||
nest build | ||
|
||
# pm2 실행 또는 리로드 | ||
if pm2 list | grep -q "LocalMingle-BE"; then | ||
echo "> reload application" | ||
pm2 reload LocalMingle-BE | ||
else | ||
echo "> start application" | ||
pm2 start dist/src/main.js --name LocalMingle-BE | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters