diff --git a/.github/workflows/cd-dev.yml b/.github/workflows/cd-dev.yml new file mode 100644 index 0000000..c8db0d9 --- /dev/null +++ b/.github/workflows/cd-dev.yml @@ -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 + diff --git a/.github/workflows/cd-prod.yml b/.github/workflows/cd-prod.yml new file mode 100644 index 0000000..53981e0 --- /dev/null +++ b/.github/workflows/cd-prod.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e02933b --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/package.json b/package.json index 1895b90..0805cf4 100644 --- a/package.json +++ b/package.json @@ -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 .",