Files
ucef 44ae524626
AS Talange CI/CD Pipeline / Build & Run Unit Tests (push) Successful in 3m47s
AS Talange CI/CD Pipeline / Deploy to Test Environment (push) Successful in 4m22s
ci: ajout d'une vérification de démarrage après le déploiement
2026-06-25 09:47:54 +02:00

74 lines
2.4 KiB
YAML

name: AS Talange CI/CD Pipeline
on:
push:
branches:
- main
jobs:
test:
name: Build & Run Unit Tests
runs-on: [self-hosted, ubuntu-latest]
container:
image: maven:3.9.6-eclipse-temurin-21
steps:
- name: Clone repository
run: |
if ! command -v git &> /dev/null; then
apt-get update && apt-get install -y git
fi
SERVER_URL="${{ github.server_url }}"
SERVER_NO_PROTO="${SERVER_URL#http://}"
SERVER_NO_PROTO="${SERVER_NO_PROTO#https://}"
git clone "https://oauth2:${{ secrets.GITHUB_TOKEN }}@${SERVER_NO_PROTO}/${{ github.repository }}.git" .
git checkout ${{ github.sha }}
- name: Run Maven Tests
run: mvn clean test
deploy_test:
name: Deploy to Test Environment
needs: test
if: github.ref == 'refs/heads/main'
runs-on: [self-hosted, ubuntu-latest]
container:
image: docker:latest
steps:
- name: Clone repository
run: |
apk add --no-cache git
SERVER_URL="${{ github.server_url }}"
SERVER_NO_PROTO="${SERVER_URL#http://}"
SERVER_NO_PROTO="${SERVER_NO_PROTO#https://}"
git clone "https://oauth2:${{ secrets.GITHUB_TOKEN }}@${SERVER_NO_PROTO}/${{ github.repository }}.git" .
git checkout ${{ github.sha }}
- name: Deploy with Docker Compose
env:
DB_USER: ${{ secrets.DB_USER }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
run: |
echo "POSTGRES_USER=${DB_USER:-myuser}" > .env
echo "POSTGRES_PASSWORD=${DB_PASSWORD:-mypassword}" >> .env
echo "CAPTCHA_SECRET=1x0000000000000000000000000000000AA" >> .env
echo "CAPTCHA_SITEKEY=1x00000000000000000000AA" >> .env
docker compose down app || true
docker compose up -d --build app
- name: Verify application startup
run: |
echo "Waiting for application to start..."
COUNT=0
while [ $COUNT -lt 30 ]; do
if docker exec astalange_app wget -qO- http://localhost:8080/login | grep -q "Connexion"; then
echo "Application is up and login page is accessible!"
exit 0
fi
echo "Waiting... ($COUNT/30)"
sleep 5
COUNT=$((COUNT+1))
done
echo "Application failed to start or login page is not accessible."
docker logs astalange_app
exit 1