- Update Gitea configuration (remove DEFAULT_ACTIONS_URL) - Fix deployment documentation - Update Ansible playbooks - Clean up deprecated files - Add new deployment scripts and templates
93 lines
2.6 KiB
Bash
Executable File
93 lines
2.6 KiB
Bash
Executable File
#!/bin/bash
|
||
# Complete setup script for PHP CI image and runner registration
|
||
# This builds the CI image, loads it into docker-dind, and updates runner labels
|
||
|
||
set -e
|
||
|
||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||
|
||
echo "🚀 Setting up PHP CI Image for Gitea Runner"
|
||
echo ""
|
||
|
||
# Step 1: Build CI Image
|
||
echo "📦 Step 1: Building CI Docker Image..."
|
||
cd "$PROJECT_ROOT"
|
||
./deployment/gitea-runner/build-ci-image.sh
|
||
|
||
# Step 2: Load image into docker-dind
|
||
echo ""
|
||
echo "📥 Step 2: Loading image into docker-dind..."
|
||
IMAGE_NAME="php-ci:latest"
|
||
docker save "${IMAGE_NAME}" | docker exec -i gitea-runner-dind docker load
|
||
|
||
echo ""
|
||
echo "✅ Image loaded into docker-dind"
|
||
echo ""
|
||
|
||
# Step 3: Check current .env
|
||
echo "📋 Step 3: Checking runner configuration..."
|
||
cd "$SCRIPT_DIR"
|
||
|
||
if [ ! -f .env ]; then
|
||
echo "⚠️ .env file not found, copying from .env.example"
|
||
cp .env.example .env
|
||
echo ""
|
||
echo "⚠️ IMPORTANT: Please edit .env and add:"
|
||
echo " - GITEA_RUNNER_REGISTRATION_TOKEN"
|
||
echo " - Update GITEA_RUNNER_LABELS to include php-ci:docker://php-ci:latest"
|
||
echo ""
|
||
read -p "Press Enter after updating .env to continue..."
|
||
fi
|
||
|
||
# Check if php-ci label is already in .env
|
||
if grep -q "php-ci:docker://php-ci:latest" .env; then
|
||
echo "✅ php-ci label already in .env"
|
||
else
|
||
echo "⚠️ php-ci label not found in .env"
|
||
echo ""
|
||
read -p "Add php-ci label to GITEA_RUNNER_LABELS? (y/N) " -n 1 -r
|
||
echo
|
||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||
# Add php-ci to labels
|
||
sed -i 's|GITEA_RUNNER_LABELS=\(.*\)|GITEA_RUNNER_LABELS=\1,php-ci:docker://php-ci:latest|' .env
|
||
echo "✅ Added php-ci label to .env"
|
||
fi
|
||
fi
|
||
|
||
# Step 4: Re-register runner
|
||
echo ""
|
||
echo "🔄 Step 4: Re-registering runner with new labels..."
|
||
read -p "Re-register runner now? This will unregister the current runner. (y/N) " -n 1 -r
|
||
echo
|
||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||
if [ -f ./unregister.sh ]; then
|
||
./unregister.sh
|
||
fi
|
||
|
||
if [ -f ./register.sh ]; then
|
||
./register.sh
|
||
else
|
||
echo "⚠️ register.sh not found, please register manually"
|
||
fi
|
||
else
|
||
echo ""
|
||
echo "ℹ️ To register manually:"
|
||
echo " cd deployment/gitea-runner"
|
||
echo " ./unregister.sh"
|
||
echo " ./register.sh"
|
||
fi
|
||
|
||
echo ""
|
||
echo "✅ Setup complete!"
|
||
echo ""
|
||
echo "📝 Summary:"
|
||
echo " - CI Image built: php-ci:latest"
|
||
echo " - Image loaded into docker-dind"
|
||
echo " - Runner labels updated (restart runner to apply)"
|
||
echo ""
|
||
echo "🎯 Next steps:"
|
||
echo " 1. Verify runner is registered with php-ci label in Gitea UI"
|
||
echo " 2. Test workflows using runs-on: php-ci"
|
||
echo ""
|