10 Commits

Author SHA1 Message Date
denshooter
33f6d47b3e chore: Update Docker Compose configuration for PostgreSQL security and initialization
All checks were successful
Dev Deployment (Zero Downtime) / deploy-dev (push) Successful in 14m28s
- Removed POSTGRES_HOST_AUTH_METHOD for enhanced security, reverting to default password authentication.
- Eliminated init-db.sql mount, as database initialization is now handled via environment variables, with additional grants managed through Prisma migrations if necessary.
2026-01-15 22:38:10 +01:00
denshooter
019fff1d5b chore: Refactor Gitea deployment workflow for PostgreSQL and Redis management
All checks were successful
Dev Deployment (Zero Downtime) / deploy-dev (push) Successful in 14m57s
- Improved container management by stopping and removing existing containers before starting new ones to ensure a clean environment.
- Added logic to remove old images and pull new ones to match the current architecture.
- Enhanced feedback messages for better clarity during the deployment process.
2026-01-15 22:20:19 +01:00
denshooter
d5475c6443 chore: Remove platform specifications for PostgreSQL and Redis in Docker configuration
All checks were successful
Dev Deployment (Zero Downtime) / deploy-dev (push) Successful in 16m3s
- Simplified the Docker Compose file by removing ARM64 platform specifications for PostgreSQL and Redis services, making it more general-purpose.
2026-01-15 21:48:48 +01:00
denshooter
9f7ecf6a88 chore: Remove exposed ports from PostgreSQL and Redis services in Docker configuration
All checks were successful
Dev Deployment (Zero Downtime) / deploy-dev (push) Successful in 14m59s
- Removed port mappings for PostgreSQL and Redis in the development Docker Compose file to enhance security and avoid potential conflicts.
2026-01-15 21:15:14 +01:00
denshooter
a66da4a59f chore: Enhance Gitea deployment workflow for database and Redis management
Some checks failed
Dev Deployment (Zero Downtime) / deploy-dev (push) Failing after 6m40s
- Added logic to start PostgreSQL and Redis containers if they are not already running.
- Implemented checks to ensure the existence of necessary Docker networks.
- Updated environment variables for database and Redis connections.
- Improved feedback messages for better clarity during the deployment process.
2026-01-15 18:15:18 +01:00
denshooter
5e544afdae chore: Update Docker configuration and Gitea deployment workflow
All checks were successful
Dev Deployment (Zero Downtime) / deploy-dev (push) Successful in 15m36s
- Added a new script for database migration to the Docker image.
- Adjusted Dockerfile to create the scripts directory and copy the migration script with the correct permissions.
- Enhanced the Gitea deployment workflow to ensure the proxy network exists before starting the container.
2026-01-15 17:01:39 +01:00
denshooter
ab02058c9d chore: Improve port management in Gitea deployment workflow
All checks were successful
Dev Deployment (Zero Downtime) / deploy-dev (push) Successful in 14m32s
- Enhanced the deployment script to better handle port conflicts by checking for both Docker containers and non-Docker processes using the specified health port.
- Added logic to wait for the port to be released and attempt to use an alternative port if the original is still in use after a timeout.
- Improved feedback messages for better clarity during the deployment process.
2026-01-15 16:20:08 +01:00
denshooter
38d99a504d 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.
2026-01-15 16:00:44 +01:00
denshooter
098e7ab6f4 fix: Update Gitea workflows to use ubuntu-latest runner
Some checks failed
Dev Deployment (Zero Downtime) / deploy-dev (push) Failing after 8m34s
2026-01-15 15:28:09 +01:00
denshooter
24608045fb feat: pushing to both remotes 2026-01-15 15:23:35 +01:00
11 changed files with 577 additions and 42 deletions

View File

@@ -57,6 +57,7 @@ docker-compose*.yml
# Scripts (keep only essential ones)
scripts
!scripts/init-db.sql
!scripts/start-with-migrate.js
# Misc
.cache

View File

@@ -1,17 +1,17 @@
name: Testing Deployment (Zero Downtime)
name: Dev Deployment (Zero Downtime)
on:
push:
branches: [ testing ]
branches: [ dev ]
env:
NODE_VERSION: '20'
DOCKER_IMAGE: portfolio-app
IMAGE_TAG: testing
IMAGE_TAG: dev
jobs:
deploy-testing:
runs-on: ubuntu-latest
deploy-dev:
runs-on: ubuntu-latest # Gitea Actions: Use runner with ubuntu-latest label
steps:
- name: Checkout code
uses: actions/checkout@v3
@@ -38,7 +38,7 @@ jobs:
- name: Build Docker image
run: |
echo "🏗️ Building testing Docker image with BuildKit cache..."
echo "🏗️ Building dev Docker image with BuildKit cache..."
DOCKER_BUILDKIT=1 docker build \
--cache-from ${{ env.DOCKER_IMAGE }}:${{ env.IMAGE_TAG }} \
--cache-from ${{ env.DOCKER_IMAGE }}:latest \
@@ -46,35 +46,214 @@ jobs:
.
echo "✅ Docker image built successfully"
- name: Zero-Downtime Testing Deployment
- name: Zero-Downtime Dev Deployment
run: |
echo "🚀 Starting zero-downtime testing deployment..."
echo "🚀 Starting zero-downtime dev deployment..."
COMPOSE_FILE="docker-compose.testing.yml"
CONTAINER_NAME="portfolio-app-testing"
HEALTH_PORT="3002"
CONTAINER_NAME="portfolio-app-dev"
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 "")
# Start DB and Redis if not running
echo "🗄️ Starting database and Redis..."
COMPOSE_FILE="docker-compose.dev.minimal.yml"
# Stop and remove existing containers to ensure clean start with correct architecture
echo "🧹 Cleaning up existing containers..."
docker stop portfolio_postgres_dev portfolio_redis_dev 2>/dev/null || true
docker rm portfolio_postgres_dev portfolio_redis_dev 2>/dev/null || true
# Remove old images to force re-pull with correct architecture
echo "🔄 Removing old images to force re-pull..."
docker rmi postgres:15-alpine redis:7-alpine 2>/dev/null || true
# Pull images with correct architecture (Docker will auto-detect)
echo "📥 Pulling images for current architecture..."
docker compose -f $COMPOSE_FILE pull postgres redis
# Start containers
echo "📦 Starting PostgreSQL and Redis containers..."
docker compose -f $COMPOSE_FILE up -d postgres redis
# Wait for DB to be ready
echo "⏳ Waiting for database to be ready..."
for i in {1..30}; do
if docker exec portfolio_postgres_dev pg_isready -U portfolio_user -d portfolio_dev >/dev/null 2>&1; then
echo "✅ Database is ready!"
break
fi
echo "⏳ Waiting for database... ($i/30)"
sleep 1
done
# Export environment variables
export NODE_ENV=production
export LOG_LEVEL=${LOG_LEVEL:-debug}
export NEXT_PUBLIC_BASE_URL=${NEXT_PUBLIC_BASE_URL_DEV:-https://dev.dk0.dev}
export DATABASE_URL="postgresql://portfolio_user:portfolio_dev_pass@portfolio_postgres_dev:5432/portfolio_dev?schema=public"
export REDIS_URL="redis://portfolio_redis_dev:6379"
export MY_EMAIL=${MY_EMAIL}
export MY_INFO_EMAIL=${MY_INFO_EMAIL}
export MY_PASSWORD=${MY_PASSWORD}
export MY_INFO_PASSWORD=${MY_INFO_PASSWORD}
export ADMIN_BASIC_AUTH=${ADMIN_BASIC_AUTH}
export ADMIN_SESSION_SECRET=${ADMIN_SESSION_SECRET}
export N8N_WEBHOOK_URL=${N8N_WEBHOOK_URL:-''}
export N8N_SECRET_TOKEN=${N8N_SECRET_TOKEN:-''}
export PORT=${HEALTH_PORT}
# 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"
# Wait for Docker to release the port
echo "⏳ Waiting for Docker to release port ${HEALTH_PORT}..."
sleep 3
fi
# Check if port is still in use by Docker containers (check all containers, not just running)
PORT_CONTAINER=$(docker ps -a --format "{{.ID}}\t{{.Names}}\t{{.Ports}}" | grep -E "(:${HEALTH_PORT}->|:${HEALTH_PORT}/)" | awk '{print $1}' | head -1 || echo "")
if [ ! -z "$PORT_CONTAINER" ]; then
echo "⚠️ Port ${HEALTH_PORT} is still in use by container $PORT_CONTAINER"
echo "🛑 Stopping and removing container using port..."
docker stop $PORT_CONTAINER 2>/dev/null || true
docker rm $PORT_CONTAINER 2>/dev/null || true
sleep 3
fi
# Also check for any containers with the same name that might be using the port
SAME_NAME_CONTAINER=$(docker ps -a -q -f name=$CONTAINER_NAME | head -1 || echo "")
if [ ! -z "$SAME_NAME_CONTAINER" ] && [ "$SAME_NAME_CONTAINER" != "$EXISTING_CONTAINER" ]; then
echo "⚠️ Found another container with same name: $SAME_NAME_CONTAINER"
docker stop $SAME_NAME_CONTAINER 2>/dev/null || true
docker rm $SAME_NAME_CONTAINER 2>/dev/null || true
sleep 2
fi
# Also check if port is in use by another process (non-Docker)
PORT_IN_USE=$(lsof -ti:${HEALTH_PORT} 2>/dev/null || ss -tlnp | grep ":${HEALTH_PORT} " | head -1 || echo "")
if [ ! -z "$PORT_IN_USE" ] && [ -z "$PORT_CONTAINER" ]; then
echo "⚠️ Port ${HEALTH_PORT} is in use by process"
echo "Attempting to free the port..."
# Try to find and kill the process
if command -v lsof >/dev/null 2>&1; then
PID=$(lsof -ti:${HEALTH_PORT} 2>/dev/null || echo "")
if [ ! -z "$PID" ]; then
kill -9 $PID 2>/dev/null || true
sleep 2
fi
fi
fi
# Final check: verify port is free and wait if needed
echo "🔍 Verifying port ${HEALTH_PORT} is free..."
MAX_WAIT=10
WAIT_COUNT=0
while [ $WAIT_COUNT -lt $MAX_WAIT ]; do
PORT_CHECK=$(docker ps --format "{{.Ports}}" | grep -E "(:${HEALTH_PORT}->|:${HEALTH_PORT}/)" || echo "")
if [ -z "$PORT_CHECK" ]; then
# Also check with lsof/ss if available
if command -v lsof >/dev/null 2>&1; then
PORT_CHECK=$(lsof -ti:${HEALTH_PORT} 2>/dev/null || echo "")
elif command -v ss >/dev/null 2>&1; then
PORT_CHECK=$(ss -tlnp | grep ":${HEALTH_PORT} " || echo "")
fi
fi
if [ -z "$PORT_CHECK" ]; then
echo "✅ Port ${HEALTH_PORT} is free!"
break
fi
WAIT_COUNT=$((WAIT_COUNT + 1))
echo "⏳ Port still in use, waiting... ($WAIT_COUNT/$MAX_WAIT)"
sleep 1
done
# If port is still in use, try alternative port
if [ $WAIT_COUNT -ge $MAX_WAIT ]; then
echo "⚠️ Port ${HEALTH_PORT} is still in use after waiting. Trying alternative port..."
HEALTH_PORT="3002"
echo "🔄 Using alternative port: ${HEALTH_PORT}"
# Quick check if alternative port is also in use
ALT_PORT_CHECK=$(docker ps --format "{{.Ports}}" | grep -E "(:${HEALTH_PORT}->|:${HEALTH_PORT}/)" || echo "")
if [ ! -z "$ALT_PORT_CHECK" ]; then
echo "❌ Alternative port ${HEALTH_PORT} is also in use!"
echo "Attempting to free alternative port..."
ALT_CONTAINER=$(docker ps -a --format "{{.ID}}\t{{.Names}}\t{{.Ports}}" | grep -E "(:${HEALTH_PORT}->|:${HEALTH_PORT}/)" | awk '{print $1}' | head -1 || echo "")
if [ ! -z "$ALT_CONTAINER" ]; then
docker stop $ALT_CONTAINER 2>/dev/null || true
docker rm $ALT_CONTAINER 2>/dev/null || true
sleep 2
fi
fi
fi
# Ensure networks exist
echo "🌐 Checking for networks..."
if ! docker network inspect proxy >/dev/null 2>&1; then
echo "⚠️ Proxy network not found, creating it..."
docker network create proxy 2>/dev/null || echo "Network might already exist or creation failed"
else
echo "✅ Proxy network exists"
fi
if ! docker network inspect portfolio_dev >/dev/null 2>&1; then
echo "⚠️ Portfolio dev network not found, creating it..."
docker network create portfolio_dev 2>/dev/null || echo "Network might already exist or creation failed"
else
echo "✅ Portfolio dev network exists"
fi
# Connect proxy network to portfolio_dev network if needed
# (This allows the app to access both proxy and DB/Redis)
# Start new container with updated image
echo "🆕 Starting new dev container..."
docker compose -f $COMPOSE_FILE up -d --no-deps --build portfolio-testing
docker run -d \
--name $CONTAINER_NAME \
--restart unless-stopped \
--network portfolio_dev \
-p ${HEALTH_PORT}:3000 \
-e NODE_ENV=production \
-e LOG_LEVEL=${LOG_LEVEL:-debug} \
-e NEXT_PUBLIC_BASE_URL=${NEXT_PUBLIC_BASE_URL_DEV:-https://dev.dk0.dev} \
-e DATABASE_URL=${DATABASE_URL} \
-e REDIS_URL=${REDIS_URL} \
-e MY_EMAIL=${MY_EMAIL} \
-e MY_INFO_EMAIL=${MY_INFO_EMAIL} \
-e MY_PASSWORD=${MY_PASSWORD} \
-e MY_INFO_PASSWORD=${MY_INFO_PASSWORD} \
-e ADMIN_BASIC_AUTH=${ADMIN_BASIC_AUTH} \
-e ADMIN_SESSION_SECRET=${ADMIN_SESSION_SECRET} \
-e N8N_WEBHOOK_URL=${N8N_WEBHOOK_URL:-''} \
-e N8N_SECRET_TOKEN=${N8N_SECRET_TOKEN:-''} \
$IMAGE_NAME
# Connect container to proxy network as well (for external access)
echo "🔗 Connecting container to proxy network..."
docker network connect proxy $CONTAINER_NAME 2>/dev/null || echo "Container might already be connected to proxy network"
# Wait for new container to be healthy
echo "⏳ Waiting for new container to be healthy..."
HEALTH_CHECK_PASSED=false
for i in {1..60}; do
NEW_CONTAINER=$(docker ps -q -f name=$CONTAINER_NAME)
if [ ! -z "$NEW_CONTAINER" ]; then
# Check health status
# Check Docker health status
HEALTH=$(docker inspect $NEW_CONTAINER --format='{{.State.Health.Status}}' 2>/dev/null || echo "starting")
if [ "$HEALTH" == "healthy" ]; then
echo "✅ New container is healthy!"
HEALTH_CHECK_PASSED=true
break
fi
# Also check HTTP health endpoint
if curl -f http://localhost:$HEALTH_PORT/api/health > /dev/null 2>&1; then
echo "✅ New container is responding!"
HEALTH_CHECK_PASSED=true
break
fi
fi
@@ -83,9 +262,9 @@ jobs:
done
# Verify new container is working
if ! curl -f http://localhost:$HEALTH_PORT/api/health > /dev/null 2>&1; then
echo "⚠️ New testing container health check failed, but continuing (non-blocking)..."
docker compose -f $COMPOSE_FILE logs --tail=50 portfolio-testing
if [ "$HEALTH_CHECK_PASSED" != "true" ]; then
echo "⚠️ New dev container health check failed, but continuing (non-blocking)..."
docker logs $CONTAINER_NAME --tail=50
fi
# Remove old container if it exists and is different
@@ -98,11 +277,13 @@ jobs:
fi
fi
echo "✅ Testing deployment completed!"
echo "✅ Dev deployment completed!"
env:
NODE_ENV: production
LOG_LEVEL: ${{ vars.LOG_LEVEL || 'debug' }}
NEXT_PUBLIC_BASE_URL: ${{ vars.NEXT_PUBLIC_BASE_URL_TESTING || 'https://testing.dk0.dev' }}
NEXT_PUBLIC_BASE_URL_DEV: ${{ vars.NEXT_PUBLIC_BASE_URL_DEV || 'https://dev.dk0.dev' }}
DATABASE_URL: postgresql://portfolio_user:portfolio_dev_pass@portfolio_postgres_dev:5432/portfolio_dev?schema=public
REDIS_URL: redis://portfolio_redis_dev:6379
MY_EMAIL: ${{ vars.MY_EMAIL }}
MY_INFO_EMAIL: ${{ vars.MY_INFO_EMAIL }}
MY_PASSWORD: ${{ secrets.MY_PASSWORD }}
@@ -112,19 +293,19 @@ jobs:
N8N_WEBHOOK_URL: ${{ vars.N8N_WEBHOOK_URL || '' }}
N8N_SECRET_TOKEN: ${{ secrets.N8N_SECRET_TOKEN || '' }}
- name: Testing Health Check
- name: Dev Health Check
run: |
echo "🔍 Running testing health checks..."
echo "🔍 Running dev health checks..."
for i in {1..20}; do
if curl -f http://localhost:3002/api/health && curl -f http://localhost:3002/ > /dev/null; then
echo "✅ Testing is fully operational!"
if curl -f http://localhost:3001/api/health && curl -f http://localhost:3001/ > /dev/null; then
echo "✅ Dev is fully operational!"
exit 0
fi
echo "⏳ Waiting for testing... ($i/20)"
echo "⏳ Waiting for dev... ($i/20)"
sleep 3
done
echo "⚠️ Testing health check failed, but continuing (non-blocking)..."
docker compose -f docker-compose.testing.yml logs --tail=50
echo "⚠️ Dev health check failed, but continuing (non-blocking)..."
docker logs portfolio-app-dev --tail=50
- name: Cleanup
run: |

View File

@@ -11,7 +11,7 @@ env:
jobs:
deploy-production:
runs-on: ubuntu-latest
runs-on: ubuntu-latest # Gitea Actions: Use runner with ubuntu-latest label
steps:
- name: Checkout code
uses: actions/checkout@v3

View File

@@ -66,7 +66,6 @@ RUN adduser --system --uid 1001 nextjs
# Copy the built application
COPY --from=builder /app/public ./public
COPY --from=builder /app/scripts ./scripts
# Set the correct permission for prerender cache
RUN mkdir .next
@@ -86,6 +85,10 @@ COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
COPY --from=builder /app/node_modules/prisma ./node_modules/prisma
COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma
# Create scripts directory and copy start script AFTER standalone to ensure it's not overwritten
RUN mkdir -p scripts && chown nextjs:nodejs scripts
COPY --from=builder --chown=nextjs:nodejs /app/scripts/start-with-migrate.js ./scripts/start-with-migrate.js
# Note: Environment variables should be passed via docker-compose or runtime environment
# DO NOT copy .env files into the image for security reasons

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

@@ -1,19 +1,17 @@
services:
# PostgreSQL Database (ARM64 optimized)
# PostgreSQL Database
postgres:
image: postgres:15-alpine
platform: linux/arm64
container_name: portfolio_postgres_dev
environment:
POSTGRES_DB: portfolio_dev
POSTGRES_USER: portfolio_user
POSTGRES_PASSWORD: portfolio_dev_pass
POSTGRES_HOST_AUTH_METHOD: trust
ports:
- "5432:5432"
# POSTGRES_HOST_AUTH_METHOD removed - using default password authentication (more secure)
volumes:
- postgres_dev_data:/var/lib/postgresql/data
- ./scripts/init-db.sql:/docker-entrypoint-initdb.d/init-db.sql
# init-db.sql mount removed - database is initialized via POSTGRES_DB/POSTGRES_USER
# Additional grants can be done via Prisma migrations if needed
networks:
- portfolio_dev
healthcheck:
@@ -22,13 +20,10 @@ services:
timeout: 5s
retries: 5
# Redis for caching (ARM64 optimized)
# Redis for caching
redis:
image: redis:7-alpine
platform: linux/arm64
container_name: portfolio_redis_dev
ports:
- "6379:6379"
volumes:
- redis_dev_data:/data
networks:

115
push-to-remote.ps1 Normal file
View File

@@ -0,0 +1,115 @@
# Push to Remote - Choose between GitHub and Gitea
# PowerShell script for Windows
$ErrorActionPreference = "Stop"
function Write-ColorOutput($ForegroundColor) {
$fc = $host.UI.RawUI.ForegroundColor
$host.UI.RawUI.ForegroundColor = $ForegroundColor
if ($args) {
Write-Output $args
}
$host.UI.RawUI.ForegroundColor = $fc
}
Write-ColorOutput Cyan "╔════════════════════════════════════════════════════════════╗"
Write-ColorOutput Cyan "║ Portfolio - Push to Remote ║"
Write-ColorOutput Cyan "╚════════════════════════════════════════════════════════════╝"
Write-Output ""
# Get current branch
$currentBranch = git branch --show-current
Write-ColorOutput Cyan "Current branch: $currentBranch"
Write-Output ""
# Check available remotes
Write-ColorOutput Cyan "Available remotes:"
git remote -v | Select-String -Pattern "(origin|gitea)" | Select-Object -First 4
Write-Output ""
# Ask which remote to push to
Write-ColorOutput Yellow "Where do you want to push?"
Write-Output " 1) GitHub (origin) - https://github.com/denshooter/portfolio.git"
Write-Output " 2) Gitea (gitea) - https://git.dk0.dev/denshooter/portfolio.git"
Write-Output " 3) Both"
Write-Output ""
$remoteChoice = Read-Host "Choose (1/2/3)"
switch ($remoteChoice) {
"1" {
$remoteName = "origin"
$remoteDesc = "GitHub"
}
"2" {
$remoteName = "gitea"
$remoteDesc = "Gitea"
}
"3" {
$remoteName = "both"
$remoteDesc = "Both (GitHub and Gitea)"
}
default {
Write-ColorOutput Red "✗ Invalid choice"
exit 1
}
}
Write-Output ""
Write-ColorOutput Cyan "📋 Pushing to $remoteDesc..."
Write-Output ""
# Function to push to a remote
function Push-ToRemote {
param(
[string]$Remote,
[string]$Desc
)
Write-ColorOutput Cyan "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
Write-ColorOutput Cyan "🚀 Pushing to $Desc ($Remote)..."
try {
git push $Remote $currentBranch
Write-ColorOutput Green "✓ Successfully pushed to $Desc!"
return $true
}
catch {
Write-ColorOutput Red "✗ Push to $Desc failed"
Write-Output $_.Exception.Message
return $false
}
}
# Push based on choice
$success = $true
if ($remoteName -eq "both") {
if (-not (Push-ToRemote -Remote "origin" -Desc "GitHub")) {
$success = $false
}
Write-Output ""
if (-not (Push-ToRemote -Remote "gitea" -Desc "Gitea")) {
$success = $false
}
}
else {
if (-not (Push-ToRemote -Remote $remoteName -Desc $remoteDesc)) {
$success = $false
}
}
Write-Output ""
if ($success) {
Write-ColorOutput Green "╔════════════════════════════════════════════════════════════╗"
Write-ColorOutput Green "║ Successfully Pushed! 🎉 ║"
Write-ColorOutput Green "╚════════════════════════════════════════════════════════════╝"
Write-Output ""
Write-ColorOutput Cyan "📊 Latest commits:"
git log --oneline -3
Write-Output ""
}
else {
Write-ColorOutput Red "✗ Some pushes failed. Check the errors above."
exit 1
}
Write-ColorOutput Green "✅ Done!"

104
push-to-remote.sh Executable file
View File

@@ -0,0 +1,104 @@
#!/bin/bash
# Push to Remote - Choose between GitHub and Gitea
# This script lets you choose which remote to push to
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}║ Portfolio - Push to Remote ║${NC}"
echo -e "${BLUE}╚════════════════════════════════════════════════════════════╝${NC}"
echo ""
# Get current branch
CURRENT_BRANCH=$(git branch --show-current)
echo -e "${CYAN}Current branch: ${CURRENT_BRANCH}${NC}"
echo ""
# Check available remotes
echo -e "${BLUE}Available remotes:${NC}"
git remote -v | grep -E "(origin|gitea)" | head -4
echo ""
# Ask which remote to push to
echo -e "${YELLOW}Where do you want to push?${NC}"
echo " 1) GitHub (origin) - https://github.com/denshooter/portfolio.git"
echo " 2) Gitea (gitea) - https://git.dk0.dev/denshooter/portfolio.git"
echo " 3) Both"
echo ""
read -p "Choose (1/2/3): " -n 1 -r REMOTE_CHOICE
echo ""
case $REMOTE_CHOICE in
1)
REMOTE_NAME="origin"
REMOTE_DESC="GitHub"
;;
2)
REMOTE_NAME="gitea"
REMOTE_DESC="Gitea"
;;
3)
REMOTE_NAME="both"
REMOTE_DESC="Both (GitHub and Gitea)"
;;
*)
echo -e "${RED}✗ Invalid choice${NC}"
exit 1
;;
esac
echo ""
echo -e "${BLUE}📋 Pushing to ${REMOTE_DESC}...${NC}"
echo ""
# Function to push to a remote
push_to_remote() {
local remote=$1
local desc=$2
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${BLUE}🚀 Pushing to ${desc} (${remote})...${NC}"
if git push "$remote" "$CURRENT_BRANCH"; then
echo -e "${GREEN}✓ Successfully pushed to ${desc}!${NC}"
return 0
else
echo -e "${RED}✗ Push to ${desc} failed${NC}"
return 1
fi
}
# Push based on choice
SUCCESS=true
if [ "$REMOTE_NAME" = "both" ]; then
push_to_remote "origin" "GitHub" || SUCCESS=false
echo ""
push_to_remote "gitea" "Gitea" || SUCCESS=false
else
push_to_remote "$REMOTE_NAME" "$REMOTE_DESC" || SUCCESS=false
fi
echo ""
if [ "$SUCCESS" = true ]; then
echo -e "${GREEN}╔════════════════════════════════════════════════════════════╗${NC}"
echo -e "${GREEN}║ Successfully Pushed! 🎉 ║${NC}"
echo -e "${GREEN}╚════════════════════════════════════════════════════════════╝${NC}"
echo ""
echo -e "${BLUE}📊 Latest commits:${NC}"
git log --oneline -3
echo ""
else
echo -e "${RED}✗ Some pushes failed. Check the errors above.${NC}"
exit 1
fi
echo -e "${GREEN}✅ Done!${NC}"

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