chore: update ci-cd.yml
This commit is contained in:
@@ -1,56 +1,106 @@
|
||||
name: Final Network Test
|
||||
name: CI/CD Pipeline für michaelschiemer.de
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, develop ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
env:
|
||||
REGISTRY_URL: docker-registry:5000
|
||||
#GITEA_URL: 127.0.0.1:3000
|
||||
GITEA_URL: gitea:3000
|
||||
REGISTRY_URL: 127.0.0.1:5000 # Host network access
|
||||
IMAGE_NAME: michaelschiemer
|
||||
|
||||
jobs:
|
||||
test-connectivity:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: catthehacker/ubuntu:act-latest
|
||||
options: --add-host=gitea:127.0.0.1 --add-host=docker-registry:127.0.0.1
|
||||
services:
|
||||
redis:
|
||||
image: redis:8-alpine
|
||||
options: --add-host=gitea:127.0.0.1 --add-host=docker-registry:127.0.0.1
|
||||
mariadb:
|
||||
image: mariadb:latest
|
||||
env:
|
||||
MYSQL_ROOT_PASSWORD: test
|
||||
MYSQL_DATABASE: test
|
||||
options: --add-host=gitea:127.0.0.1 --add-host=docker-registry:127.0.0.1
|
||||
|
||||
steps:
|
||||
# - name: Test Network and DNS
|
||||
# run: |
|
||||
# echo "🔍 Testing network connectivity..."
|
||||
# echo "Host entries:"
|
||||
# cat /etc/hosts
|
||||
# echo "IP-Konfiguration:"
|
||||
# ip addr
|
||||
# echo "Network interfaces:"
|
||||
# ifconfig || ip addr
|
||||
# echo "Testing Gitea connectivity (127.0.0.1):"
|
||||
# curl -s -o /dev/null -w "%{http_code} - Gitea Status\n" http://${GITEA_URL} || echo "❌ Cannot reach Gitea"
|
||||
# echo "Testing Registry connectivity (127.0.0.1):"
|
||||
# curl -s -o /dev/null -w "%{http_code} - Registry Status\n" http://${REGISTRY_URL}/v2/ || echo "❌ Cannot reach Registry"
|
||||
# echo "Alternativer lokaler Test:"
|
||||
# curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:3000 || echo "❌ Cannot reach Gitea via 127.0.0.1"
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '18'
|
||||
|
||||
- name: Test Registry Login
|
||||
run: |
|
||||
echo "🔐 Testing registry login..."
|
||||
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ env.REGISTRY_URL }} -u admin --password-stdin
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.4'
|
||||
extensions: gd, zip, pdo, pdo_mysql, opcache, pcntl, posix, shmop, redis
|
||||
tools: composer
|
||||
|
||||
- name: Build Test Image
|
||||
run: |
|
||||
echo "🏗️ Building test image..."
|
||||
echo 'FROM alpine:latest' > Dockerfile
|
||||
echo 'RUN echo "Test successful"' >> Dockerfile
|
||||
docker build -t ${{ env.REGISTRY_URL }}/${{ env.IMAGE_NAME }}/test:latest .
|
||||
docker push ${{ env.REGISTRY_URL }}/${{ env.IMAGE_NAME }}/test:latest
|
||||
- name: Install Dependencies
|
||||
run: composer install --no-progress --prefer-dist --optimize-autoloader
|
||||
|
||||
- name: Success
|
||||
run: |
|
||||
echo "🎉 All tests passed!"
|
||||
echo "✅ Network connectivity working"
|
||||
echo "✅ Checkout successful"
|
||||
echo "✅ Registry login working"
|
||||
echo "✅ Docker build and push working"
|
||||
- name: Build Frontend Assets
|
||||
run: npm install && npm run build
|
||||
|
||||
- name: Run Tests
|
||||
run: ./vendor/bin/pest
|
||||
env:
|
||||
DB_HOST: mariadb
|
||||
DB_PORT: 3306
|
||||
DB_DATABASE: test
|
||||
DB_USERNAME: root
|
||||
DB_PASSWORD: test
|
||||
REDIS_HOST: redis
|
||||
REDIS_PORT: 6379
|
||||
|
||||
build:
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: catthehacker/ubuntu:act-latest
|
||||
options: --add-host=gitea:127.0.0.1 --add-host=docker-registry:127.0.0.1
|
||||
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Login to Private Registry
|
||||
run: < /dev/null |
|
||||
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ env.REGISTRY_URL }} -u admin --password-stdin
|
||||
|
||||
- name: Determine Image Tag
|
||||
id: tag
|
||||
run: |
|
||||
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
|
||||
echo "tag=latest" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "tag=develop" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Build and Push Images
|
||||
run: |
|
||||
# Build and push PHP image
|
||||
if [ -f docker/php/Dockerfile ]; then
|
||||
docker build -t ${{ env.REGISTRY_URL }}/${{ env.IMAGE_NAME }}/php:${{ steps.tag.outputs.tag }} -f docker/php/Dockerfile .
|
||||
docker push ${{ env.REGISTRY_URL }}/${{ env.IMAGE_NAME }}/php:${{ steps.tag.outputs.tag }}
|
||||
fi
|
||||
|
||||
# Build and push Nginx image
|
||||
if [ -f docker/nginx/Dockerfile ]; then
|
||||
docker build -t ${{ env.REGISTRY_URL }}/${{ env.IMAGE_NAME }}/nginx:${{ steps.tag.outputs.tag }} -f docker/nginx/Dockerfile .
|
||||
docker push ${{ env.REGISTRY_URL }}/${{ env.IMAGE_NAME }}/nginx:${{ steps.tag.outputs.tag }}
|
||||
fi
|
||||
|
||||
# Build and push Worker image
|
||||
if [ -f docker/worker/Dockerfile ]; then
|
||||
docker build -t ${{ env.REGISTRY_URL }}/${{ env.IMAGE_NAME }}/worker:${{ steps.tag.outputs.tag }} -f docker/worker/Dockerfile .
|
||||
docker push ${{ env.REGISTRY_URL }}/${{ env.IMAGE_NAME }}/worker:${{ steps.tag.outputs.tag }}
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user