Skip to content

fix bug issue

fix bug issue #148

name: Deploy Backend
on:
push:
branches:
- development
- production
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
service:
- "services/auth-api"
- "services/user-api"
- "services/post-api"
# Add other services here
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Install dependencies
run: npm install
working-directory: ./backend
- name: Install Serverless Framework
run: npm install -g serverless
- name: Deploy Backend
if: matrix.service == null
run: |
if [ "${{ github.ref }}" == "refs/heads/production" ]; then
serverless deploy --stage production
else
serverless deploy --stage dev
fi
working-directory: ./backend
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SERVERLESS_ACCESS_KEY: ${{ secrets.SERVERLESS_ACCESS_KEY }}
COGNITO_CLIENT_ID: ${{ secrets.COGNITO_CLIENT_ID }}
COGNITO_USER_POOL_ID: ${{ secrets.COGNITO_USER_POOL_ID }}
COGNITO_CLIENT_SECRET: ${{ secrets.COGNITO_CLIENT_SECRET }}
SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }}
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}
- name: Deploy Other Services
if: matrix.service != null
run: |
if [ "${{ github.ref }}" == "refs/heads/production" ]; then
serverless deploy --stage production
else
serverless deploy --stage dev
fi
working-directory: ./backend/${{ matrix.service }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SERVERLESS_ACCESS_KEY: ${{ secrets.SERVERLESS_ACCESS_KEY }}
USERS_TABLE: ${{ secrets.USERS_TABLE }}
COGNITO_CLIENT_ID: ${{ secrets.COGNITO_CLIENT_ID }}
COGNITO_USER_POOL_ID: ${{ secrets.COGNITO_USER_POOL_ID }}
COGNITO_CLIENT_SECRET: ${{ secrets.COGNITO_CLIENT_SECRET }}
SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }}
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}