This commit is contained in:
60
.github/workflows/deploy.yml
vendored
Normal file
60
.github/workflows/deploy.yml
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
name: Deploy Apartment API
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '18'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Build Docker image
|
||||
run: |
|
||||
docker build -t apartment-api:${{ github.sha }} .
|
||||
docker tag apartment-api:${{ github.sha }} apartment-api:latest
|
||||
|
||||
- name: Deploy to server
|
||||
run: |
|
||||
# Copy files to deployment directory
|
||||
mkdir -p /media/stephen/Storage_Linux/infrastructure/services/apartment-api
|
||||
cp -r . /media/stephen/Storage_Linux/infrastructure/services/apartment-api/
|
||||
|
||||
# Navigate to deployment directory
|
||||
cd /media/stephen/Storage_Linux/infrastructure/services/apartment-api
|
||||
|
||||
# Stop existing container if running
|
||||
docker compose down || true
|
||||
|
||||
# Start new container
|
||||
docker compose up -d
|
||||
|
||||
# Clean up old images
|
||||
docker image prune -f
|
||||
|
||||
- name: Verify deployment
|
||||
run: |
|
||||
# Wait for container to start
|
||||
sleep 15
|
||||
|
||||
# Check if container is running
|
||||
docker ps | grep apartment-api
|
||||
|
||||
# Test health endpoint
|
||||
curl -f http://localhost:3000/health || echo "API may still be starting..."
|
||||
|
||||
# Test API endpoint
|
||||
curl -f http://localhost:3000/api/daily-summary || echo "API may still be loading data..."
|
||||
Reference in New Issue
Block a user