Update: Verwende repository.michaelschiemer.de:5000 für Git-Repository URLs
- Ändere Remote-URL zu repository.michaelschiemer.de:5000 - Aktualisiere alle Workflows (production-deploy, test-registry, security-scan, update-production-secrets) - Test: Production Deployment Workflow
This commit is contained in:
@@ -29,16 +29,16 @@ jobs:
|
||||
# Use CI token if available, otherwise try public access
|
||||
if [ -n "${{ secrets.CI_TOKEN }}" ]; then
|
||||
git clone --depth 1 --branch "$REF_NAME" \
|
||||
"https://${{ secrets.CI_TOKEN }}@git.michaelschiemer.de/${REPO}.git" \
|
||||
"https://${{ secrets.CI_TOKEN }}@repository.michaelschiemer.de:5000/${REPO}.git" \
|
||||
/workspace/repo
|
||||
else
|
||||
# Try public HTTPS (works if repository is public)
|
||||
git clone --depth 1 --branch "$REF_NAME" \
|
||||
"https://git.michaelschiemer.de/${REPO}.git" \
|
||||
"https://repository.michaelschiemer.de:5000/${REPO}.git" \
|
||||
/workspace/repo || \
|
||||
# Fallback: Try to use Gitea's internal runner access
|
||||
git clone --depth 1 \
|
||||
"https://git.michaelschiemer.de/${REPO}.git" \
|
||||
"https://repository.michaelschiemer.de:5000/${REPO}.git" \
|
||||
/workspace/repo
|
||||
fi
|
||||
|
||||
@@ -127,16 +127,16 @@ jobs:
|
||||
# Use CI token if available, otherwise try public access
|
||||
if [ -n "${{ secrets.CI_TOKEN }}" ]; then
|
||||
git clone --depth 1 --branch "$REF_NAME" \
|
||||
"https://${{ secrets.CI_TOKEN }}@git.michaelschiemer.de/${REPO}.git" \
|
||||
"https://${{ secrets.CI_TOKEN }}@repository.michaelschiemer.de:5000/${REPO}.git" \
|
||||
/workspace/repo
|
||||
else
|
||||
# Try public HTTPS (works if repository is public)
|
||||
git clone --depth 1 --branch "$REF_NAME" \
|
||||
"https://git.michaelschiemer.de/${REPO}.git" \
|
||||
"https://repository.michaelschiemer.de:5000/${REPO}.git" \
|
||||
/workspace/repo || \
|
||||
# Fallback: Try to use Gitea's internal runner access
|
||||
git clone --depth 1 \
|
||||
"https://git.michaelschiemer.de/${REPO}.git" \
|
||||
"https://repository.michaelschiemer.de:5000/${REPO}.git" \
|
||||
/workspace/repo
|
||||
fi
|
||||
|
||||
@@ -238,7 +238,7 @@ jobs:
|
||||
echo ""
|
||||
echo "🔍 Teste Registry: $TEST_URL"
|
||||
|
||||
# Wenn URL bereits Port enthält, teste direkt (HTTP)
|
||||
# Wenn URL bereits Port 5000 enthält, teste HTTP (Fallback)
|
||||
if [[ "$TEST_URL" == *":5000" ]]; then
|
||||
# Direkter HTTP-Zugriff (Port bereits in URL)
|
||||
echo " Versuche HTTP-Zugriff auf http://$TEST_URL/v2/"
|
||||
@@ -299,7 +299,10 @@ jobs:
|
||||
if [ $LOGIN_EXIT_CODE -eq 0 ]; then
|
||||
echo "✅ Erfolgreich bei Registry angemeldet: $TEST_URL"
|
||||
REGISTRY_URL="$TEST_URL"
|
||||
ACTUAL_REGISTRY="$TEST_URL"
|
||||
LOGIN_SUCCESS=true
|
||||
echo "REGISTRY_URL=$TEST_URL" >> $GITHUB_ENV
|
||||
echo "ACTUAL_REGISTRY=$TEST_URL" >> $GITHUB_ENV
|
||||
break
|
||||
else
|
||||
echo "⚠️ Login fehlgeschlagen für $TEST_URL (Exit Code: $LOGIN_EXIT_CODE)"
|
||||
@@ -309,33 +312,91 @@ jobs:
|
||||
echo "⚠️ Registry nicht erreichbar: http://$TEST_URL (Status: $HTTP_CODE)"
|
||||
fi
|
||||
else
|
||||
# Teste HTTPS zuerst
|
||||
if curl -k -s -f -o /dev/null "https://$TEST_URL/v2/" 2>/dev/null; then
|
||||
echo "✅ Registry erreichbar über HTTPS: https://$TEST_URL"
|
||||
# Domain ohne Port - teste HTTPS zuerst (empfohlen, keine insecure-registry nötig!)
|
||||
echo " Versuche HTTPS-Zugriff auf https://$TEST_URL/v2/"
|
||||
# Stelle sicher, dass curl verfügbar ist
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
apk add --no-cache curl ca-certificates >/dev/null 2>&1 || true
|
||||
fi
|
||||
HTTPS_CODE=$(curl -k -s -o /dev/null -w "%{http_code}" "https://$TEST_URL/v2/" 2>&1 || echo "000")
|
||||
# Debug: Wenn curl fehlschlägt, zeige mehr Details
|
||||
if [ "$HTTPS_CODE" = "000" ]; then
|
||||
echo " ⚠️ curl Fehler beim HTTPS-Test"
|
||||
CURL_VERBOSE=$(curl -k -v "https://$TEST_URL/v2/" 2>&1 | head -20)
|
||||
echo " curl Verbose Output:"
|
||||
echo "$CURL_VERBOSE" | while IFS= read -r line; do
|
||||
echo " $line"
|
||||
done || true
|
||||
fi
|
||||
echo " HTTPS-Status: $HTTPS_CODE"
|
||||
|
||||
# 404 könnte bedeuten, dass die Route nicht richtig konfiguriert ist
|
||||
# 401 ist gut (Registry erreichbar, Auth erforderlich)
|
||||
# 200 ist auch gut (Auth erfolgreich oder nicht erforderlich)
|
||||
if [ "$HTTPS_CODE" = "401" ] || [ "$HTTPS_CODE" = "200" ]; then
|
||||
echo "✅ Registry erreichbar über HTTPS: https://$TEST_URL (Status: $HTTPS_CODE)"
|
||||
|
||||
# Versuche Login
|
||||
if echo "$REGISTRY_PASSWORD" | docker login "$TEST_URL" -u "$REGISTRY_USER" --password-stdin 2>&1; then
|
||||
echo "✅ Erfolgreich bei Registry angemeldet: $TEST_URL"
|
||||
# Versuche Login via HTTPS (keine insecure-registry nötig!)
|
||||
echo " Versuche Docker Login über HTTPS..."
|
||||
set +e
|
||||
LOGIN_OUTPUT=$(echo "$REGISTRY_PASSWORD" | docker login "$TEST_URL" -u "$REGISTRY_USER" --password-stdin 2>&1)
|
||||
LOGIN_EXIT_CODE=$?
|
||||
set -e
|
||||
|
||||
echo " Login-Exit-Code: $LOGIN_EXIT_CODE"
|
||||
if [ -n "$LOGIN_OUTPUT" ]; then
|
||||
echo "$LOGIN_OUTPUT" | while IFS= read -r line; do
|
||||
echo " $line"
|
||||
done || true
|
||||
fi
|
||||
|
||||
if [ $LOGIN_EXIT_CODE -eq 0 ]; then
|
||||
echo "✅ Erfolgreich bei Registry angemeldet über HTTPS: $TEST_URL"
|
||||
REGISTRY_URL="$TEST_URL"
|
||||
ACTUAL_REGISTRY="$TEST_URL"
|
||||
LOGIN_SUCCESS=true
|
||||
echo "REGISTRY_URL=$TEST_URL" >> $GITHUB_ENV
|
||||
echo "ACTUAL_REGISTRY=$TEST_URL" >> $GITHUB_ENV
|
||||
break
|
||||
else
|
||||
echo "⚠️ Login fehlgeschlagen für $TEST_URL, versuche HTTP..."
|
||||
echo "⚠️ HTTPS-Login fehlgeschlagen für $TEST_URL, versuche HTTP als Fallback..."
|
||||
fi
|
||||
else
|
||||
echo "⚠️ Registry nicht erreichbar über HTTPS: https://$TEST_URL (Status: $HTTPS_CODE)"
|
||||
fi
|
||||
|
||||
# Teste HTTP (falls HTTPS nicht funktioniert)
|
||||
if curl -s -f -o /dev/null "http://$TEST_URL:5000/v2/" 2>/dev/null; then
|
||||
echo "✅ Registry erreichbar über HTTP: http://$TEST_URL:5000"
|
||||
# Fallback: Teste HTTP (falls HTTPS nicht funktioniert)
|
||||
echo " Versuche HTTP-Zugriff auf http://$TEST_URL:5000/v2/ (Fallback)"
|
||||
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "http://$TEST_URL:5000/v2/" 2>&1 || echo "000")
|
||||
echo " HTTP-Status: $HTTP_CODE"
|
||||
|
||||
if [ "$HTTP_CODE" = "401" ] || [ "$HTTP_CODE" = "200" ]; then
|
||||
echo "✅ Registry erreichbar über HTTP: http://$TEST_URL:5000 (Status: $HTTP_CODE)"
|
||||
|
||||
# Versuche Login mit HTTP
|
||||
if echo "$REGISTRY_PASSWORD" | docker login "$TEST_URL:5000" -u "$REGISTRY_USER" --password-stdin 2>&1; then
|
||||
echo "✅ Erfolgreich bei Registry angemeldet: $TEST_URL:5000"
|
||||
# Versuche Login mit HTTP (benötigt insecure-registry Konfiguration)
|
||||
echo " Versuche Docker Login über HTTP (benötigt insecure-registry)..."
|
||||
set +e
|
||||
LOGIN_OUTPUT=$(echo "$REGISTRY_PASSWORD" | docker login "$TEST_URL:5000" -u "$REGISTRY_USER" --password-stdin 2>&1)
|
||||
LOGIN_EXIT_CODE=$?
|
||||
set -e
|
||||
|
||||
echo " Login-Exit-Code: $LOGIN_EXIT_CODE"
|
||||
if [ -n "$LOGIN_OUTPUT" ]; then
|
||||
echo "$LOGIN_OUTPUT" | while IFS= read -r line; do
|
||||
echo " $line"
|
||||
done || true
|
||||
fi
|
||||
|
||||
if [ $LOGIN_EXIT_CODE -eq 0 ]; then
|
||||
echo "✅ Erfolgreich bei Registry angemeldet über HTTP: $TEST_URL:5000"
|
||||
REGISTRY_URL="$TEST_URL:5000"
|
||||
ACTUAL_REGISTRY="$TEST_URL:5000"
|
||||
LOGIN_SUCCESS=true
|
||||
echo "REGISTRY_URL=$TEST_URL:5000" >> $GITHUB_ENV
|
||||
echo "ACTUAL_REGISTRY=$TEST_URL:5000" >> $GITHUB_ENV
|
||||
break
|
||||
else
|
||||
echo "⚠️ Login fehlgeschlagen für $TEST_URL:5000, versuche nächste URL..."
|
||||
echo "⚠️ HTTP-Login fehlgeschlagen für $TEST_URL:5000, versuche nächste URL..."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@@ -356,23 +417,47 @@ jobs:
|
||||
echo "Password vorhanden: $([ -n "$REGISTRY_PASSWORD" ] && echo 'Ja' || echo 'Nein')"
|
||||
echo ""
|
||||
echo "Mögliche Ursachen:"
|
||||
echo "1. Registry nicht vom Runner-Container aus erreichbar (Netzwerk-Isolation)"
|
||||
echo "2. Falsche Credentials in Gitea Secrets"
|
||||
echo "3. Registry-DNS nicht auflösbar vom Container aus"
|
||||
echo "4. Registry läuft nicht oder ist nicht erreichbar"
|
||||
echo "1. ⚠️ WICHTIG: Docker-daemon (docker-dind) muss neu gestartet werden nach Änderungen an insecure-registry"
|
||||
echo " - Stoppe: docker compose -f deployment/gitea-runner/docker-compose.yml stop docker-dind"
|
||||
echo " - Starte: docker compose -f deployment/gitea-runner/docker-compose.yml up -d docker-dind"
|
||||
echo "2. Registry nicht vom Runner-Container aus erreichbar (Netzwerk-Isolation)"
|
||||
echo "3. Falsche Credentials in Gitea Secrets (REGISTRY_USER, REGISTRY_PASSWORD)"
|
||||
echo "4. Registry-DNS nicht auflösbar vom Container aus"
|
||||
echo "5. Registry läuft nicht oder ist nicht erreichbar"
|
||||
echo ""
|
||||
echo "Lösung: Prüfe die Secrets in Gitea und stelle sicher, dass die Registry erreichbar ist"
|
||||
echo "Lösungsschritte:"
|
||||
echo "1. Stelle sicher, dass docker-compose.yml alle Registry-URLs in --insecure-registry Flags enthält"
|
||||
echo "2. Starte docker-dind Container NEU (siehe oben)"
|
||||
echo "3. Prüfe die Secrets in Gitea (REGISTRY_USER, REGISTRY_PASSWORD)"
|
||||
echo "4. Teste Registry-Erreichbarkeit: curl http://94.16.110.151:5000/v2/"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "✅ Registry-Login erfolgreich!"
|
||||
echo "📦 Verwendete Registry URL: $REGISTRY_URL"
|
||||
|
||||
# Stelle sicher, dass ACTUAL_REGISTRY gesetzt ist (für Build-Step)
|
||||
if [ -z "$ACTUAL_REGISTRY" ]; then
|
||||
ACTUAL_REGISTRY="$REGISTRY_URL"
|
||||
echo "ACTUAL_REGISTRY=$REGISTRY_URL" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Build and push Docker image
|
||||
shell: bash
|
||||
env:
|
||||
ACTUAL_REGISTRY: ${{ env.ACTUAL_REGISTRY }}
|
||||
run: |
|
||||
cd /workspace/repo
|
||||
|
||||
# Fallback falls ACTUAL_REGISTRY nicht gesetzt wurde
|
||||
if [ -z "$ACTUAL_REGISTRY" ]; then
|
||||
echo "⚠️ ACTUAL_REGISTRY nicht gesetzt, verwende Fallback: ${{ env.REGISTRY }}"
|
||||
ACTUAL_REGISTRY="${{ env.REGISTRY }}"
|
||||
fi
|
||||
|
||||
echo "📦 Verwendete Registry für Build: $ACTUAL_REGISTRY"
|
||||
|
||||
COMMIT_SHA="${{ github.sha }}"
|
||||
if [ -z "$COMMIT_SHA" ]; then
|
||||
COMMIT_SHA=$(git rev-parse HEAD)
|
||||
@@ -424,16 +509,16 @@ jobs:
|
||||
# Use CI token if available, otherwise try public access
|
||||
if [ -n "${{ secrets.CI_TOKEN }}" ]; then
|
||||
git clone --depth 1 --branch "$REF_NAME" \
|
||||
"https://${{ secrets.CI_TOKEN }}@git.michaelschiemer.de/${REPO}.git" \
|
||||
"https://${{ secrets.CI_TOKEN }}@repository.michaelschiemer.de:5000/${REPO}.git" \
|
||||
/workspace/repo
|
||||
else
|
||||
# Try public HTTPS (works if repository is public)
|
||||
git clone --depth 1 --branch "$REF_NAME" \
|
||||
"https://git.michaelschiemer.de/${REPO}.git" \
|
||||
"https://repository.michaelschiemer.de:5000/${REPO}.git" \
|
||||
/workspace/repo || \
|
||||
# Fallback: Try to use Gitea's internal runner access
|
||||
git clone --depth 1 \
|
||||
"https://git.michaelschiemer.de/${REPO}.git" \
|
||||
"https://repository.michaelschiemer.de:5000/${REPO}.git" \
|
||||
/workspace/repo
|
||||
fi
|
||||
|
||||
|
||||
@@ -27,16 +27,16 @@ jobs:
|
||||
# Use CI token if available, otherwise try public access
|
||||
if [ -n "${{ secrets.CI_TOKEN }}" ]; then
|
||||
git clone --depth 1 --branch "$REF_NAME" \
|
||||
"https://${{ secrets.CI_TOKEN }}@git.michaelschiemer.de/${REPO}.git" \
|
||||
"https://${{ secrets.CI_TOKEN }}@repository.michaelschiemer.de:5000/${REPO}.git" \
|
||||
/workspace/repo
|
||||
else
|
||||
# Try public HTTPS (works if repository is public)
|
||||
git clone --depth 1 --branch "$REF_NAME" \
|
||||
"https://git.michaelschiemer.de/${REPO}.git" \
|
||||
"https://repository.michaelschiemer.de:5000/${REPO}.git" \
|
||||
/workspace/repo || \
|
||||
# Fallback: Try to use Gitea's internal runner access
|
||||
git clone --depth 1 \
|
||||
"https://git.michaelschiemer.de/${REPO}.git" \
|
||||
"https://repository.michaelschiemer.de:5000/${REPO}.git" \
|
||||
/workspace/repo
|
||||
fi
|
||||
|
||||
|
||||
61
.gitea/workflows/test-registry.yml
Normal file
61
.gitea/workflows/test-registry.yml
Normal file
@@ -0,0 +1,61 @@
|
||||
name: Test Registry Credentials
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [ main ]
|
||||
paths:
|
||||
- 'scripts/test-registry-credentials.sh'
|
||||
- '.gitea/workflows/test-registry.yml'
|
||||
|
||||
env:
|
||||
REGISTRY_DOMAIN: registry.michaelschiemer.de
|
||||
REGISTRY_HOST: 94.16.110.151
|
||||
|
||||
jobs:
|
||||
test-credentials:
|
||||
name: Test Registry Credentials
|
||||
runs-on: docker-build
|
||||
steps:
|
||||
- name: Install git and setup environment
|
||||
shell: sh
|
||||
run: |
|
||||
if ! command -v bash >/dev/null 2>&1 || ! command -v git >/dev/null 2>&1 || ! command -v curl >/dev/null 2>&1; then
|
||||
apk add --no-cache git bash curl ca-certificates
|
||||
fi
|
||||
|
||||
- name: Checkout code
|
||||
shell: bash
|
||||
run: |
|
||||
REF_NAME="${{ github.ref_name }}"
|
||||
REPO="${{ github.repository }}"
|
||||
if [ -z "$REF_NAME" ]; then
|
||||
REF_NAME="main"
|
||||
fi
|
||||
|
||||
if [ -n "${{ secrets.CI_TOKEN }}" ]; then
|
||||
git clone --depth 1 --branch "$REF_NAME" \
|
||||
"https://${{ secrets.CI_TOKEN }}@repository.michaelschiemer.de:5000/${REPO}.git" \
|
||||
/workspace/repo
|
||||
else
|
||||
git clone --depth 1 --branch "$REF_NAME" \
|
||||
"https://repository.michaelschiemer.de:5000/${REPO}.git" \
|
||||
/workspace/repo || \
|
||||
git clone --depth 1 \
|
||||
"https://repository.michaelschiemer.de:5000/${REPO}.git" \
|
||||
/workspace/repo
|
||||
fi
|
||||
|
||||
cd /workspace/repo
|
||||
|
||||
- name: Test Registry Credentials
|
||||
shell: bash
|
||||
env:
|
||||
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
|
||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
REGISTRY_DOMAIN: ${{ env.REGISTRY_DOMAIN }}
|
||||
REGISTRY_HOST: ${{ env.REGISTRY_HOST }}
|
||||
REGISTRY_PORT: 5000
|
||||
run: |
|
||||
cd /workspace/repo
|
||||
./scripts/test-registry-credentials.sh
|
||||
@@ -14,18 +14,34 @@ env:
|
||||
jobs:
|
||||
deploy-secrets:
|
||||
name: Deploy Secrets to Production
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: php-ci # Uses pre-built PHP 8.5 CI image with Ansible
|
||||
environment:
|
||||
name: production-secrets
|
||||
url: https://michaelschiemer.de
|
||||
|
||||
steps:
|
||||
- name: Checkout deployment configuration
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: |
|
||||
deployment/ansible
|
||||
sparse-checkout-cone-mode: false
|
||||
run: |
|
||||
REF_NAME="${{ github.ref_name }}"
|
||||
REPO="${{ github.repository }}"
|
||||
if [ -z "$REF_NAME" ]; then
|
||||
REF_NAME="main"
|
||||
fi
|
||||
|
||||
if [ -n "${{ secrets.CI_TOKEN }}" ]; then
|
||||
git clone --depth 1 --branch "$REF_NAME" \
|
||||
"https://${{ secrets.CI_TOKEN }}@repository.michaelschiemer.de:5000/${REPO}.git" \
|
||||
/workspace/repo
|
||||
else
|
||||
git clone --depth 1 --branch "$REF_NAME" \
|
||||
"https://repository.michaelschiemer.de:5000/${REPO}.git" \
|
||||
/workspace/repo || \
|
||||
git clone --depth 1 \
|
||||
"https://repository.michaelschiemer.de:5000/${REPO}.git" \
|
||||
/workspace/repo
|
||||
fi
|
||||
|
||||
cd /workspace/repo
|
||||
|
||||
- name: Setup SSH key
|
||||
run: |
|
||||
@@ -34,10 +50,9 @@ jobs:
|
||||
chmod 600 ~/.ssh/production
|
||||
ssh-keyscan -H ${{ env.DEPLOYMENT_HOST }} >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Install Ansible
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y ansible
|
||||
# Ansible is pre-installed in php-ci image
|
||||
- name: Verify Ansible installation
|
||||
run: ansible --version
|
||||
|
||||
- name: Create vault password file
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user