diff --git a/.github/workflows/cd-production.yml b/.github/workflows/cd-production.yml new file mode 100644 index 0000000..bb91a52 --- /dev/null +++ b/.github/workflows/cd-production.yml @@ -0,0 +1,35 @@ +name: Deploy Kaapi to EC2 Production + +on: + push: + tags: + - "v*" # Deploy only when tags like v1.0.0, v2.1.0, etc., are created + +jobs: + deploy: + runs-on: ubuntu-latest + environment: AWS_PRODUCTION_ENV + + permissions: + packages: write + contents: read + attestations: write + id-token: write + + steps: + - name: Checkout Repository + uses: actions/checkout@v6 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v6 + with: + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Deploy via SSM + run: | + aws ssm send-command \ + --instance-ids "${{ secrets.EC2_INSTANCE_ID }}" \ + --document-name "AWS-RunShellScript" \ + --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 }}"]' \ + --region ${{ secrets.AWS_REGION }} diff --git a/.github/workflows/cd-staging.yml b/.github/workflows/cd-staging.yml new file mode 100644 index 0000000..dd9c2cd --- /dev/null +++ b/.github/workflows/cd-staging.yml @@ -0,0 +1,35 @@ +name: Deploy Kaapi to EC2 Staging + +on: + push: + branches: + - main # Deploy only when changes are pushed to the main branch + +jobs: + deploy: + runs-on: ubuntu-latest + environment: AWS_STAGING_ENV + + permissions: + packages: write + contents: read + attestations: write + id-token: write + + steps: + - name: Checkout Repository + uses: actions/checkout@v6 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v6 + with: + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Deploy via SSM + run: | + aws ssm send-command \ + --instance-ids "${{ secrets.EC2_INSTANCE_ID }}" \ + --document-name "AWS-RunShellScript" \ + --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 }}"]' \ + --region ${{ secrets.AWS_REGION }} diff --git a/README.md b/README.md index 67701c9..6911dbe 100644 --- a/README.md +++ b/README.md @@ -137,20 +137,27 @@ Deployments are automated via a GitHub Actions CD pipeline that SSHes into the E ### Branch Strategy -| Branch | Environment | -| --------- | ----------- | -| `main` | Staging | -| `release` | Production | +| Trigger | Environment | +| ------------------------------------- | ----------- | +| Push to `main` | Staging | +| Tag matching `v*.*.*` (e.g. `v1.0.0`) | Production | ### Pipeline Steps -On every push to `main` or `release`, the pipeline automatically: +**Staging** — on every push to `main`, the pipeline automatically: 1. SSHes into the EC2 instance 2. Runs `git pull` to fetch the latest code 3. Runs `npm run build` to create an optimized production build 4. Restarts the server to apply the new build +**Production** — on every version tag (e.g. `v1.0.0`, `v2.1.0`), the pipeline automatically: + +1. SSHes into the EC2 instance +2. Runs `git fetch --tags` and checks out the tag +3. Runs `npm run build` to create an optimized production build +4. Restarts the server to apply the new build + --- ## Learn More diff --git a/app/(main)/configurations/prompt-editor/page.tsx b/app/(main)/configurations/prompt-editor/page.tsx index 7e4b4e0..3c51ce6 100644 --- a/app/(main)/configurations/prompt-editor/page.tsx +++ b/app/(main)/configurations/prompt-editor/page.tsx @@ -396,19 +396,8 @@ function PromptEditorContent() { style={{ backgroundColor: colors.bg.secondary }} >
-
-

+

+

Loading configuration...