Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
47 changes: 47 additions & 0 deletions .github/workflows/cd-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Deploy Kaapi to EC2 Production

on:
push:
branches:
- release
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Production uses the release branch, as discussed in the GitHub issue.

For reference, you can check it here: #22 (comment)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for confusion, my exact statement was this: can use main branch for staging and use release for production same way the Kaapi-backend is working or else use dev branch for staging and main branch for prod

Here I want to say use release means GitHub release not branch name release ... again sorry for the confusion

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have update the flow same as the backend so in the production automation deployment only run when tags like v1.0.0, v2.1.0, etc., are created. and also updated the Readme accordingly.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great


jobs:
deploy:
name: Deploy Kaapi Frontend to EC2 Production
runs-on: ubuntu-latest
environment: AWS_PRODUCTION_ENV

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Deploy via SSH
uses: appleboy/ssh-action@v1.0.3
env:
PM2_APP_NAME: ${{ secrets.PM2_APP_NAME }}
BUILD_DIRECTORY: ${{ secrets.BUILD_DIRECTORY }}
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_SSH_KEY }}
script_stop: true
script: |
set -e

echo "=== Navigating to Project Directory ==="
cd $BUILD_DIRECTORY

echo "=== Fetch Latest Code ==="
git pull origin release

echo "=== Stop Running Application ==="
pm2 stop "$PM2_APP_NAME" || true

echo "=== Install Dependencies ==="
npm ci

echo "=== Build Application ==="
npm run build

echo "=== Start Application ==="
pm2 start "$PM2_APP_NAME"
47 changes: 47 additions & 0 deletions .github/workflows/cd-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Deploy Kaapi to EC2 Staging

on:
push:
branches:
- main

jobs:
deploy:
name: Deploy Kaapi Frontend to EC2 Staging
runs-on: ubuntu-latest
environment: AWS_STAGING_ENV

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Deploy via SSH
uses: appleboy/ssh-action@v1.0.3
env:
PM2_APP_NAME: ${{ secrets.PM2_APP_NAME }}
BUILD_DIRECTORY: ${{ secrets.BUILD_DIRECTORY }}
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_SSH_KEY }}
script_stop: true
script: |
set -e

echo "=== Navigating to Project Directory ==="
cd $BUILD_DIRECTORY

echo "=== Fetch Latest Code ==="
git pull origin main

echo "=== Stop Running Application ==="
pm2 stop "$PM2_APP_NAME" || true

echo "=== Install Dependencies ==="
npm ci

echo "=== Build Application ==="
npm run build

echo "=== Start Application ==="
pm2 start "$PM2_APP_NAME"