chore: Enhance Gitea deployment workflow and add Gitea runner status check script
Some checks failed
Dev Deployment (Zero Downtime) / deploy-dev (push) Failing after 7m46s
Some checks failed
Dev Deployment (Zero Downtime) / deploy-dev (push) Failing after 7m46s
- Updated deployment script to check for existing containers and free ports before starting a new container. - Added a new script to check the status of the Gitea runner, including service checks, running processes, Docker containers, common directories, and network connections.
This commit is contained in:
@@ -54,8 +54,8 @@ jobs:
|
||||
HEALTH_PORT="3001"
|
||||
IMAGE_NAME="${{ env.DOCKER_IMAGE }}:${{ env.IMAGE_TAG }}"
|
||||
|
||||
# Backup current container ID if running
|
||||
OLD_CONTAINER=$(docker ps -q -f name=$CONTAINER_NAME || echo "")
|
||||
# Check for existing container (running or stopped)
|
||||
EXISTING_CONTAINER=$(docker ps -aq -f name=$CONTAINER_NAME || echo "")
|
||||
|
||||
# Export environment variables
|
||||
export NODE_ENV=production
|
||||
@@ -71,11 +71,21 @@ jobs:
|
||||
export N8N_SECRET_TOKEN=${N8N_SECRET_TOKEN:-''}
|
||||
export PORT=${HEALTH_PORT}
|
||||
|
||||
# Stop and remove old container if it exists
|
||||
if [ ! -z "$OLD_CONTAINER" ]; then
|
||||
echo "🛑 Stopping old container..."
|
||||
docker stop $OLD_CONTAINER 2>/dev/null || true
|
||||
docker rm $OLD_CONTAINER 2>/dev/null || true
|
||||
# Stop and remove existing container if it exists (running or stopped)
|
||||
if [ ! -z "$EXISTING_CONTAINER" ]; then
|
||||
echo "🛑 Stopping and removing existing container..."
|
||||
docker stop $EXISTING_CONTAINER 2>/dev/null || true
|
||||
docker rm $EXISTING_CONTAINER 2>/dev/null || true
|
||||
echo "✅ Old container removed"
|
||||
fi
|
||||
|
||||
# Also check if port is in use by another process and free it
|
||||
PORT_IN_USE=$(lsof -ti:${HEALTH_PORT} 2>/dev/null || echo "")
|
||||
if [ ! -z "$PORT_IN_USE" ]; then
|
||||
echo "⚠️ Port ${HEALTH_PORT} is in use by process $PORT_IN_USE"
|
||||
echo "Attempting to free the port..."
|
||||
kill -9 $PORT_IN_USE 2>/dev/null || true
|
||||
sleep 2
|
||||
fi
|
||||
|
||||
# Start new container with updated image
|
||||
|
||||
Reference in New Issue
Block a user