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

[INFRA] CI/CD 환경 구축 #25

Merged
merged 17 commits into from
Nov 18, 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: 44 additions & 0 deletions .github/workflows/cd-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: SOPT Notification Development Server CD

on:
workflow_dispatch:
push:
branches: [ develop ]

job:
deploy:
name: Deploy to AWS Lambda
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: uses: actions/checkout@v3

- name: Set Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'

- name: Install Dependencies
run: npm ci

- name: Create Env File
env:
ENV_FILE: ${{ secrets.ENV_DEV }}
run: |
touch .env.dev
echo "$ENV_FILE" >> .env.dev

- name: Set AWS Credentials by export
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
export AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}
export AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}
export AWS_REGION=${{ secrets.AWS_REGION }}

- name: Deploy
run: npm run deploy:dev

43 changes: 43 additions & 0 deletions .github/workflows/cd-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: SOPT Notification Production Server CD

on:
workflow_dispatch:
push:
branches: [ main ]

job:
deploy:
name: Deploy to AWS Lambda
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: uses: actions/checkout@v3

- name: Set Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'

- name: Install Dependencies
run: npm ci

- name: Create Env File
env:
ENV_FILE: ${{ secrets.ENV_PROD }}
run: |
touch .env.prod
echo "$ENV_FILE" >> .env.prod

- name: Set AWS Credentials by export
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
export AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}
export AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}
export AWS_REGION=${{ secrets.AWS_REGION }}

- name: Deploy
run: npm run deploy:prod
45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: SOPT Notification Server CI

on:
workflow_dispatch:
pull_request:
branches: [ develop ]

jobs:
validate:
name: Build
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'

- name: Install Dependencies
run: npm ci

- name: Build Project
run: npm run build

- name: Run Serverless-offline
env:
ENV_FILE: ${{ secrets.ENV_DEV }}
run: |
touch .env.dev
echo "$ENV_FILE" >> .env.dev
nohup npm run start > nohup.out 2>&1 &

sleep 5

if grep -q "Server ready" nohup.out; then
echo "Application Run Success."
else
echo "Application Run Fail."
exit 1
fi
shell: bash
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc --build --clean",
"watch": "tsc -w",
"lint": "eslint .",
"format": "prettier --write .",
Expand Down
Loading