Skip to content

Commit

Permalink
[CHORE] 개발/배포 환경분리 세팅
Browse files Browse the repository at this point in the history
  • Loading branch information
leGit-y committed Oct 31, 2023
1 parent ff42b92 commit 797b485
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 1 deletion.
66 changes: 66 additions & 0 deletions .github/workflows/cd_develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: CD

on:
push:
branches: [develop]

jobs:
build-and-deploy:
runs-on: ubuntu-20.04

strategy:
matrix:
node-version: [18.11.0]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- name: Checkout source code.
uses: actions/checkout@v3

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'

- name: Create env file
working-directory: ./
run: |
pwd
touch .env
echo DATABASE_URL=${{ secrets.TEST_DATABASE_URL }} >> .env
echo JWT_SECRET=${{ secrets.JWT_SECRET }} >> .env
echo JWT_ALGO=${{ secrets.JWT_ALGO }} >> .env
echo KAKAO_CLIENT_ID=${{ secrets.KAKAO_CLIENT_ID }} >> .env
echo KAKAO_REDIRECT_URI=${{ secrets.KAKAO_REDIRECT_URI }} >> .env
echo KAKAO_SECRET_KEY=${{ secrets.KAKAO_SECRET_KEY }} >> .env
cat .env
- name: Install dependencies
working-directory: ./
run: yarn

- name: Yarn run build
working-directory: ./
run: yarn run build

- name: Zip file
run: zip -r kaera.zip ./dist ./scripts ./appspec.yml ./.env ./package.json ./prisma ./swagger.yaml

- name: AWS configure credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2

- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./kaera.zip s3://kaera-deploy-bucket/deploy/

- name: Deploy with AWS codeDeploy
run: aws deploy create-deployment
--application-name kaera-codedeploy
--deployment-config-name CodeDeployDefault.OneAtATime
--deployment-group-name dev
--s3-location bucket=kaera-deploy-bucket,bundleType=zip,key=deploy/kaera.zip

51 changes: 51 additions & 0 deletions .github/workflows/ci_develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# 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: CI

on:
pull_request:
branches: [develop]

jobs:
build-and-test:
runs-on: ubuntu-20.04

strategy:
matrix:
node-version: [18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- name: Checkout source code.
uses: actions/checkout@v3

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'

- name: Create env file
working-directory: ./
run: |
pwd
touch .env
echo DATABASE_URL=${{ secrets.TEST_DATABASE_URL }} >> .env
echo JWT_SECRET=${{ secrets.JWT_SECRET }} >> .env
echo JWT_ALGO=${{ secrets.JWT_ALGO }} >> .env
echo KAKAO_CLIENT_ID=${{ secrets.KAKAO_CLIENT_ID }} >> .env
echo KAKAO_REDIRECT_URI=${{ secrets.KAKAO_REDIRECT_URI }} >> .env
echo KAKAO_SECRET_KEY=${{ secrets.KAKAO_SECRET_KEY }} >> .env
cat .env
- name: Install dependencies
working-directory: ./
run: yarn

- name: Yarn run build
working-directory: ./
run: yarn run build

- name: Test
run: yarn test
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"api-docs": "swagger-cli bundle ./src/modules/swagger/openapi.yaml --outfile swagger.yaml --type yaml",
"predev": "npm run api-docs",
"dev": "nodemon",
"development": "dotenv -e .env.development nodemon",
"production": "dotenv -e .env.production nodemon",
"build": "tsc",
"pretest": "yarn generate",
"test": "jest",
Expand Down

0 comments on commit 797b485

Please sign in to comment.