Add deployment workflow
Some checks failed
Deploy Apartment Dashboard / deploy (push) Failing after 4m57s
Some checks failed
Deploy Apartment Dashboard / deploy (push) Failing after 4m57s
This commit is contained in:
61
.github/workflows/deploy.yml
vendored
Normal file
61
.github/workflows/deploy.yml
vendored
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
name: Deploy Apartment Dashboard
|
||||||
|
|
||||||
|
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 application
|
||||||
|
run: npm run build
|
||||||
|
|
||||||
|
- name: Build Docker image
|
||||||
|
run: |
|
||||||
|
docker build -t apartment-dashboard:${{ github.sha }} .
|
||||||
|
docker tag apartment-dashboard:${{ github.sha }} apartment-dashboard:latest
|
||||||
|
|
||||||
|
- name: Deploy to server
|
||||||
|
run: |
|
||||||
|
# Copy files to deployment directory
|
||||||
|
sudo mkdir -p /media/stephen/Storage_Linux/infrastructure/services/apartments
|
||||||
|
sudo cp -r . /media/stephen/Storage_Linux/infrastructure/services/apartments/
|
||||||
|
|
||||||
|
# Navigate to deployment directory
|
||||||
|
cd /media/stephen/Storage_Linux/infrastructure/services/apartments
|
||||||
|
|
||||||
|
# Stop existing container if running
|
||||||
|
sudo docker compose down || true
|
||||||
|
|
||||||
|
# Start new container
|
||||||
|
sudo docker compose up -d
|
||||||
|
|
||||||
|
# Clean up old images
|
||||||
|
sudo docker image prune -f
|
||||||
|
|
||||||
|
- name: Verify deployment
|
||||||
|
run: |
|
||||||
|
# Wait a moment for container to start
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
# Check if container is running
|
||||||
|
cd /media/stephen/Storage_Linux/infrastructure/services/apartments
|
||||||
|
sudo docker compose ps
|
||||||
|
|
||||||
|
# Test endpoint (optional)
|
||||||
|
curl -f http://localhost:80 || echo "Container may still be starting..."
|
||||||
Reference in New Issue
Block a user