Skip to content

Commit 8e59a68

Browse files
Automation deployment for staging and prod (#70)
Co-authored-by: Prajna Prayas <[email protected]>
1 parent bc65a03 commit 8e59a68

File tree

4 files changed

+84
-18
lines changed

4 files changed

+84
-18
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Deploy Kaapi to EC2 Production
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*" # Deploy only when tags like v1.0.0, v2.1.0, etc., are created
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
environment: AWS_PRODUCTION_ENV
12+
13+
permissions:
14+
packages: write
15+
contents: read
16+
attestations: write
17+
id-token: write
18+
19+
steps:
20+
- name: Checkout Repository
21+
uses: actions/checkout@v6
22+
23+
- name: Configure AWS credentials
24+
uses: aws-actions/configure-aws-credentials@v6
25+
with:
26+
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
27+
aws-region: ${{ secrets.AWS_REGION }}
28+
29+
- name: Deploy via SSM
30+
run: |
31+
aws ssm send-command \
32+
--instance-ids "${{ secrets.EC2_INSTANCE_ID }}" \
33+
--document-name "AWS-RunShellScript" \
34+
--parameters 'commands=["export HOME=/home/ubuntu && export PATH=/data/.nvm/versions/node/v24.11.0/bin:$PATH && git config --global --add safe.directory ${{ secrets.BUILD_DIRECTORY }} && set -e && cd ${{ secrets.BUILD_DIRECTORY }} && git pull origin main && npm ci && npm run build && sudo -u ubuntu PM2_HOME=/home/ubuntu/.pm2 /data/.nvm/versions/node/v24.11.0/bin/pm2 restart ${{ secrets.PM2_APP_NAME }}"]' \
35+
--region ${{ secrets.AWS_REGION }}

.github/workflows/cd-staging.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Deploy Kaapi to EC2 Staging
2+
3+
on:
4+
push:
5+
branches:
6+
- main # Deploy only when changes are pushed to the main branch
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
environment: AWS_STAGING_ENV
12+
13+
permissions:
14+
packages: write
15+
contents: read
16+
attestations: write
17+
id-token: write
18+
19+
steps:
20+
- name: Checkout Repository
21+
uses: actions/checkout@v6
22+
23+
- name: Configure AWS credentials
24+
uses: aws-actions/configure-aws-credentials@v6
25+
with:
26+
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
27+
aws-region: ${{ secrets.AWS_REGION }}
28+
29+
- name: Deploy via SSM
30+
run: |
31+
aws ssm send-command \
32+
--instance-ids "${{ secrets.EC2_INSTANCE_ID }}" \
33+
--document-name "AWS-RunShellScript" \
34+
--parameters 'commands=["export HOME=/home/ubuntu && export PATH=/data/.nvm/versions/node/v24.11.0/bin:$PATH && git config --global --add safe.directory ${{ secrets.BUILD_DIRECTORY }} && set -e && cd ${{ secrets.BUILD_DIRECTORY }} && git pull origin main && npm ci && npm run build && sudo -u ubuntu PM2_HOME=/home/ubuntu/.pm2 /data/.nvm/versions/node/v24.11.0/bin/pm2 restart ${{ secrets.PM2_APP_NAME }}"]' \
35+
--region ${{ secrets.AWS_REGION }}

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,20 +137,27 @@ Deployments are automated via a GitHub Actions CD pipeline that SSHes into the E
137137

138138
### Branch Strategy
139139

140-
| Branch | Environment |
141-
| --------- | ----------- |
142-
| `main` | Staging |
143-
| `release` | Production |
140+
| Trigger | Environment |
141+
| ------------------------------------- | ----------- |
142+
| Push to `main` | Staging |
143+
| Tag matching `v*.*.*` (e.g. `v1.0.0`) | Production |
144144

145145
### Pipeline Steps
146146

147-
On every push to `main` or `release`, the pipeline automatically:
147+
**Staging** — on every push to `main`, the pipeline automatically:
148148

149149
1. SSHes into the EC2 instance
150150
2. Runs `git pull` to fetch the latest code
151151
3. Runs `npm run build` to create an optimized production build
152152
4. Restarts the server to apply the new build
153153

154+
**Production** — on every version tag (e.g. `v1.0.0`, `v2.1.0`), the pipeline automatically:
155+
156+
1. SSHes into the EC2 instance
157+
2. Runs `git fetch --tags` and checks out the tag
158+
3. Runs `npm run build` to create an optimized production build
159+
4. Restarts the server to apply the new build
160+
154161
---
155162

156163
## Learn More

app/(main)/configurations/prompt-editor/page.tsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -396,19 +396,8 @@ function PromptEditorContent() {
396396
style={{ backgroundColor: colors.bg.secondary }}
397397
>
398398
<div className="flex flex-col items-center gap-3">
399-
<div
400-
className="animate-spin rounded-full border-4 border-solid"
401-
style={{
402-
width: "36px",
403-
height: "36px",
404-
borderColor: colors.bg.primary,
405-
borderTopColor: colors.accent.primary,
406-
}}
407-
/>
408-
<p
409-
className="text-sm"
410-
style={{ color: colors.text.secondary }}
411-
>
399+
<div className="animate-spin rounded-full border-4 border-solid w-9 h-9 border-bg-primary border-t-accent-primary" />
400+
<p className="text-sm text-text-secondary">
412401
Loading configuration...
413402
</p>
414403
</div>

0 commit comments

Comments
 (0)