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:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main, develop ]
|
branches: [ main, develop ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ main ]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY_URL: docker-registry:5000
|
REGISTRY_URL: 127.0.0.1:5000 # Host network access
|
||||||
#GITEA_URL: 127.0.0.1:3000
|
|
||||||
GITEA_URL: gitea:3000
|
|
||||||
IMAGE_NAME: michaelschiemer
|
IMAGE_NAME: michaelschiemer
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-connectivity:
|
test:
|
||||||
runs-on: ubuntu-latest
|
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:
|
steps:
|
||||||
# - name: Test Network and DNS
|
- name: Checkout Code
|
||||||
# run: |
|
uses: actions/checkout@v4
|
||||||
# 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
|
- name: Setup Node.js
|
||||||
uses: actions/checkout@v4
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '18'
|
||||||
|
|
||||||
- name: Test Registry Login
|
- name: Setup PHP
|
||||||
run: |
|
uses: shivammathur/setup-php@v2
|
||||||
echo "🔐 Testing registry login..."
|
with:
|
||||||
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ env.REGISTRY_URL }} -u admin --password-stdin
|
php-version: '8.4'
|
||||||
|
extensions: gd, zip, pdo, pdo_mysql, opcache, pcntl, posix, shmop, redis
|
||||||
|
tools: composer
|
||||||
|
|
||||||
- name: Build Test Image
|
- name: Install Dependencies
|
||||||
run: |
|
run: composer install --no-progress --prefer-dist --optimize-autoloader
|
||||||
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: Success
|
- name: Build Frontend Assets
|
||||||
run: |
|
run: npm install && npm run build
|
||||||
echo "🎉 All tests passed!"
|
|
||||||
echo "✅ Network connectivity working"
|
- name: Run Tests
|
||||||
echo "✅ Checkout successful"
|
run: ./vendor/bin/pest
|
||||||
echo "✅ Registry login working"
|
env:
|
||||||
echo "✅ Docker build and push working"
|
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