Skip to content

Commit e944e40

Browse files
authored
[MERGE] infra/#24 -> develop
[INFRA] CI/CD 환경 구축
2 parents 6a8fdad + 95f1472 commit e944e40

File tree

4 files changed

+133
-0
lines changed

4 files changed

+133
-0
lines changed

.github/workflows/cd-dev.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: SOPT Notification Development Server CD
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ develop ]
7+
8+
job:
9+
deploy:
10+
name: Deploy to AWS Lambda
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout Code
15+
uses: uses: actions/checkout@v3
16+
17+
- name: Set Node.js
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: 18
21+
cache: 'npm'
22+
23+
- name: Install Dependencies
24+
run: npm ci
25+
26+
- name: Create Env File
27+
env:
28+
ENV_FILE: ${{ secrets.ENV_DEV }}
29+
run: |
30+
touch .env.dev
31+
echo "$ENV_FILE" >> .env.dev
32+
33+
- name: Set AWS Credentials by export
34+
env:
35+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
36+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
37+
run: |
38+
export AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}
39+
export AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}
40+
export AWS_REGION=${{ secrets.AWS_REGION }}
41+
42+
- name: Deploy
43+
run: npm run deploy:dev
44+

.github/workflows/cd-prod.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: SOPT Notification Production Server CD
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ main ]
7+
8+
job:
9+
deploy:
10+
name: Deploy to AWS Lambda
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout Code
15+
uses: uses: actions/checkout@v3
16+
17+
- name: Set Node.js
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: 18
21+
cache: 'npm'
22+
23+
- name: Install Dependencies
24+
run: npm ci
25+
26+
- name: Create Env File
27+
env:
28+
ENV_FILE: ${{ secrets.ENV_PROD }}
29+
run: |
30+
touch .env.prod
31+
echo "$ENV_FILE" >> .env.prod
32+
33+
- name: Set AWS Credentials by export
34+
env:
35+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
36+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
37+
run: |
38+
export AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}
39+
export AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}
40+
export AWS_REGION=${{ secrets.AWS_REGION }}
41+
42+
- name: Deploy
43+
run: npm run deploy:prod

.github/workflows/ci.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: SOPT Notification Server CI
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches: [ develop ]
7+
8+
jobs:
9+
validate:
10+
name: Build
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout Code
15+
uses: actions/checkout@v3
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: 18
21+
cache: 'npm'
22+
23+
- name: Install Dependencies
24+
run: npm ci
25+
26+
- name: Build Project
27+
run: npm run build
28+
29+
- name: Run Serverless-offline
30+
env:
31+
ENV_FILE: ${{ secrets.ENV_DEV }}
32+
run: |
33+
touch .env.dev
34+
echo "$ENV_FILE" >> .env.dev
35+
nohup npm run start > nohup.out 2>&1 &
36+
37+
sleep 5
38+
39+
if grep -q "Server ready" nohup.out; then
40+
echo "Application Run Success."
41+
else
42+
echo "Application Run Fail."
43+
exit 1
44+
fi
45+
shell: bash

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"main": "index.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
8+
"build": "tsc --build --clean",
89
"watch": "tsc -w",
910
"lint": "eslint .",
1011
"format": "prettier --write .",

0 commit comments

Comments
 (0)