Skip to content
Draft
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
76 changes: 76 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Deploy Application

on:
push:
branches:
- dinura-deployment
workflow_dispatch:

permissions:
contents: read

jobs:
ci:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Backend syntax check
run: |
python -m compileall integrated-backend

- name: Frontend build
run: |
npm ci --prefix integrated-frontend
npm run build --prefix integrated-frontend

deploy:
needs: ci
runs-on: ubuntu-latest
steps:
- name: Deploy to EC2 via SSH
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.EC2_SSH_KEY }}

- name: SSH and deploy latest app
env:
EC2_HOST: ${{ secrets.EC2_HOST }}
EC2_USERNAME: ${{ secrets.EC2_USERNAME }}
run: |
set -e
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${EC2_USERNAME}@${EC2_HOST} <<'EOF'
set -e
cd ~/app
git fetch origin
git checkout dinura-deployment
git reset --hard origin/dinura-deployment

if [ ! -f .env ]; then
cp .env.example .env
fi

chmod 600 .env
sudo docker compose build
sudo docker compose up -d
sudo docker compose ps

if curl -fsS http://127.0.0.1/api/health >/dev/null 2>&1; then
echo "Backend health check passed"
else
echo "Backend health check failed"
sudo docker compose logs --tail 200 backend
exit 1
fi
EOF