Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
452 changes: 452 additions & 0 deletions .claude/CREDENTIAL_GENERATOR_README.md

Large diffs are not rendered by default.

92 changes: 92 additions & 0 deletions .github/actions/deploy-to-ec2/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: 'Deploy to EC2'
description: 'Deploy application to EC2 using SSH with venv support'

inputs:
ec2_pem_key:
description: 'EC2 PEM key content for SSH authentication'
required: true
ec2_host:
description: 'EC2 host address'
required: true
ec2_user:
description: 'EC2 SSH user'
required: true
repo_base_dir:
description: 'Base directory on EC2 where cloud-services and web-client are located'
required: false
default: '/home/ubuntu'
branch:
description: 'Git branch to deploy'
required: false
default: 'main'

runs:
using: 'composite'
steps:
- name: Configure SSH
shell: bash
run: |
mkdir -p ~/.ssh
echo "${{ inputs.ec2_pem_key }}" > ~/.ssh/ec2_deploy.pem
chmod 600 ~/.ssh/ec2_deploy.pem
cat >> ~/.ssh/config << EOF
Host ec2-deploy
HostName ${{ inputs.ec2_host }}
User ${{ inputs.ec2_user }}
IdentityFile ~/.ssh/ec2_deploy.pem
StrictHostKeyChecking no
EOF

- name: Deploy to EC2
shell: bash
run: |
ssh ec2-deploy << 'DEPLOY_EOF'
set -e

BASE_DIR="${{ inputs.repo_base_dir }}"
BRANCH="${{ inputs.branch }}"

# Deploy Web Client
echo "Deploying web-client..."
cd "$BASE_DIR/web-client"

# Update repository
git fetch origin
git checkout "$BRANCH"
git pull origin "$BRANCH"

# Build web client
npm ci
npm run build

# Restart frontend service
echo "Restarting frontend service..."
sudo systemctl restart frontend

# Deploy Cloud Services API with venv
echo "Deploying cloud-services..."
cd "$BASE_DIR/cloud-services"

# Update repository
git fetch origin
git checkout "$BRANCH"
git pull origin "$BRANCH"

# Create venv if it doesn't exist
if [ ! -d "venv" ]; then
echo "Creating virtual environment..."
python3 -m venv venv
fi

# Activate venv and install dependencies
source venv/bin/activate
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements.txt
deactivate

# Restart backend service
echo "Restarting backend service..."
sudo systemctl restart backend

echo "✅ Deployment completed successfully!"
DEPLOY_EOF
33 changes: 33 additions & 0 deletions .github/actions/install-python-requirements/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: 'Install Python Requirements'
description: 'Install Python dependencies from requirements.txt with proper path handling'

inputs:
requirements_path:
description: 'Path to requirements.txt file (relative to working_directory)'
required: false
default: 'requirements.txt'
working_directory:
description: 'Working directory where requirements.txt is located'
required: false
default: '.'
python_version:
description: 'Python version to use'
required: false
default: '3.11'

runs:
using: 'composite'
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python_version }}
cache: 'pip'
cache-dependency-path: ${{ inputs.working_directory }}/${{ inputs.requirements_path }}

- name: Install dependencies
shell: bash
working-directory: ${{ inputs.working_directory }}
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r ${{ inputs.requirements_path }}
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI/CD Pipeline

on:
pull_request:
branches: [ "main" ]
types: [opened, synchronize, reopened, closed]

jobs:
# Run tests on PRs (not on merge)
test-api:
if: github.event.action != 'closed'
uses: ./.github/workflows/test-cloud-services.yml
with:
python_version: '3.11'

test-web:
if: github.event.action != 'closed'
uses: ./.github/workflows/test-web-client.yml
with:
node_version: '20'

# Deploy when PR is merged to main
deploy:
if: github.event.pull_request.merged == true && github.event.action == 'closed'
needs: [test-api, test-web]
uses: ./.github/workflows/deploy.yml
with:
branch: 'main'
repo_base_dir: '/home/ubuntu'
secrets: inherit
43 changes: 43 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Deploy to EC2

on:
workflow_call:
inputs:
branch:
description: 'Git branch to deploy'
required: false
type: string
default: 'main'
repo_base_dir:
description: 'Base directory on EC2 where cloud-services and web-client are located'
required: false
type: string
default: '/home/ubuntu'
secrets:
EC2_PEM_KEY:
description: 'EC2 PEM key for SSH authentication'
required: true
EC2_HOST:
description: 'EC2 host address'
required: true
EC2_USER:
description: 'EC2 SSH user'
required: true

jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy to EC2

steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Deploy to EC2
uses: ./.github/actions/deploy-to-ec2
with:
ec2_pem_key: ${{ secrets.EC2_PEM_KEY }}
ec2_host: ${{ secrets.EC2_HOST }}
ec2_user: ${{ secrets.EC2_USER }}
repo_base_dir: ${{ inputs.repo_base_dir }}
branch: ${{ inputs.branch }}
104 changes: 0 additions & 104 deletions .github/workflows/test-and-deploy.yml

This file was deleted.

46 changes: 46 additions & 0 deletions .github/workflows/test-cloud-services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Test Cloud Services

on:
workflow_call:
inputs:
python_version:
description: 'Python version to use'
required: false
type: string
default: '3.11'

jobs:
test:
runs-on: ubuntu-latest
name: Test Cloud Services API

steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Install Python dependencies
uses: ./.github/actions/install-python-requirements
with:
requirements_path: requirements.txt
working_directory: cloud-services
python_version: ${{ inputs.python_version }}

- name: Install test dependencies
shell: bash
working-directory: cloud-services
run: |
pip install pytest pytest-asyncio httpx

- name: Run API tests
shell: bash
working-directory: cloud-services
run: |
pytest tests/ -v --tb=short

- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: pytest-results-cloud-services
path: cloud-services/junit/
if-no-files-found: ignore
Loading
Loading