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

- 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:
2026-01-15 16:00:44 +01:00
parent 098e7ab6f4
commit 38d99a504d
5 changed files with 156 additions and 10 deletions

View File

@@ -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

View File

@@ -81,7 +81,7 @@ export async function GET(request: NextRequest) {
let data: unknown;
try {
data = JSON.parse(raw);
} catch (parseError) {
} catch (_parseError) {
// Sometimes upstream sends HTML or a partial response; include a snippet for debugging.
const snippet = raw.slice(0, 240);
throw new Error(

View File

@@ -80,7 +80,7 @@ export async function GET(request: NextRequest) {
let data: unknown;
try {
data = JSON.parse(raw);
} catch (parseError) {
} catch (_parseError) {
// Sometimes upstream sends HTML or a partial response; include a snippet for debugging.
const snippet = raw.slice(0, 240);
throw new Error(

View File

@@ -1,6 +1,6 @@
"use client";
import { useState, useEffect } from 'react';
import { useState } from 'react';
import { motion } from 'framer-motion';
import { Heart, Code } from 'lucide-react';
import { SiGithub, SiLinkedin } from 'react-icons/si';

View File

@@ -0,0 +1,136 @@
#!/bin/bash
# Gitea Runner Status Check Script
# Prüft den Status des Gitea Runners
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
echo -e "${BLUE}╔════════════════════════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ Gitea Runner Status Check ║${NC}"
echo -e "${BLUE}╚════════════════════════════════════════════════════════════╝${NC}"
echo ""
# Check 1: systemd service
echo -e "${CYAN}[1/5] Checking systemd service...${NC}"
if systemctl list-units --type=service --all | grep -q "gitea-runner.service"; then
echo -e "${GREEN}✓ systemd service found${NC}"
systemctl status gitea-runner --no-pager -l || true
else
echo -e "${YELLOW}⚠ systemd service not found (runner might be running differently)${NC}"
fi
echo ""
# Check 2: Running processes
echo -e "${CYAN}[2/5] Checking for running runner processes...${NC}"
RUNNER_PROCESSES=$(ps aux | grep -E "(gitea|act_runner|woodpecker)" | grep -v grep || echo "")
if [ ! -z "$RUNNER_PROCESSES" ]; then
echo -e "${GREEN}✓ Found runner processes:${NC}"
echo "$RUNNER_PROCESSES" | while read line; do
echo " $line"
done
else
echo -e "${RED}✗ No runner processes found${NC}"
fi
echo ""
# Check 3: Docker containers (if runner runs in Docker)
echo -e "${CYAN}[3/5] Checking for runner Docker containers...${NC}"
RUNNER_CONTAINERS=$(docker ps -a --filter "name=runner" --format "{{.Names}}\t{{.Status}}" 2>/dev/null || echo "")
if [ ! -z "$RUNNER_CONTAINERS" ]; then
echo -e "${GREEN}✓ Found runner containers:${NC}"
echo "$RUNNER_CONTAINERS" | while read line; do
echo " $line"
done
else
echo -e "${YELLOW}⚠ No runner containers found${NC}"
fi
echo ""
# Check 4: Common runner directories
echo -e "${CYAN}[4/5] Checking common runner directories...${NC}"
RUNNER_DIRS=(
"/tmp/gitea-runner"
"/opt/gitea-runner"
"/home/*/gitea-runner"
"~/.gitea-runner"
"/usr/local/gitea-runner"
)
FOUND_DIRS=0
for dir in "${RUNNER_DIRS[@]}"; do
# Expand ~ and wildcards
EXPANDED_DIR=$(eval echo "$dir" 2>/dev/null || echo "")
if [ -d "$EXPANDED_DIR" ]; then
echo -e "${GREEN}✓ Found runner directory: $EXPANDED_DIR${NC}"
FOUND_DIRS=$((FOUND_DIRS + 1))
# Check for config files
if [ -f "$EXPANDED_DIR/.runner" ] || [ -f "$EXPANDED_DIR/config.yml" ]; then
echo " → Contains configuration files"
fi
fi
done
if [ $FOUND_DIRS -eq 0 ]; then
echo -e "${YELLOW}⚠ No runner directories found in common locations${NC}"
fi
echo ""
# Check 5: Network connections (check if runner is connecting to Gitea)
echo -e "${CYAN}[5/5] Checking network connections to Gitea...${NC}"
GITEA_URL="${GITEA_URL:-https://git.dk0.dev}"
if command -v netstat >/dev/null 2>&1; then
CONNECTIONS=$(netstat -tn 2>/dev/null | grep -E "(git.dk0.dev|3000|3001)" || echo "")
elif command -v ss >/dev/null 2>&1; then
CONNECTIONS=$(ss -tn 2>/dev/null | grep -E "(git.dk0.dev|3000|3001)" || echo "")
fi
if [ ! -z "$CONNECTIONS" ]; then
echo -e "${GREEN}✓ Found connections to Gitea:${NC}"
echo "$CONNECTIONS" | head -5
else
echo -e "${YELLOW}⚠ No active connections to Gitea found${NC}"
fi
echo ""
# Summary
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${BLUE}Summary:${NC}"
echo ""
if [ ! -z "$RUNNER_PROCESSES" ] || [ ! -z "$RUNNER_CONTAINERS" ]; then
echo -e "${GREEN}✓ Runner appears to be running${NC}"
echo ""
echo "To check runner status in Gitea:"
echo " 1. Go to: https://git.dk0.dev/denshooter/portfolio/settings/actions/runners"
echo " 2. Check if runner-01 shows as 'online' or 'idle'"
echo ""
echo "To view runner logs:"
if [ ! -z "$RUNNER_PROCESSES" ]; then
echo " - Check process logs or journalctl"
fi
if [ ! -z "$RUNNER_CONTAINERS" ]; then
echo " - docker logs <container-name>"
fi
else
echo -e "${RED}✗ Runner does not appear to be running${NC}"
echo ""
echo "To start the runner:"
echo " 1. Find where the runner binary is located"
echo " 2. Check Gitea for registration token"
echo " 3. Run: ./act_runner register --config config.yml"
echo " 4. Run: ./act_runner daemon --config config.yml"
fi
echo ""
echo -e "${CYAN}For more information, check:${NC}"
echo " - Gitea Runner Docs: https://docs.gitea.com/usage/actions/act-runner"
echo " - Runner Status: https://git.dk0.dev/denshooter/portfolio/settings/actions/runners"
echo ""