Skip to content

update name

update name #8

Workflow file for this run

name: Deploy to Production
on:
push:
branches: [ main ]
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Copy files to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_SSH_KEY }}
source: "."
target: "/opt/court-allocation"
- name: Deploy to server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
cd /opt/court-allocation
# Pull latest changes and rebuild
docker-compose pull || true
docker-compose build --no-cache
# Bring down existing containers
docker-compose down
# Start new containers
docker-compose up -d
# Clean up
docker image prune -f
# Wait for the application to start
echo "Waiting for application to start..."
sleep 15
# Health check using Host header
response=$(curl -s -o /dev/null -w "%{http_code}" -H "Host: courts.saurabhn.com" http://localhost)
if [ $response -eq 200 ]; then
echo "Application is healthy"
exit 0
else
echo "Health check failed with status: $response"
docker-compose logs
exit 1
fi