Compare commits
7 Commits
develop
...
d9ab8230a6
| Author | SHA1 | Date | |
|---|---|---|---|
| d9ab8230a6 | |||
|
|
87de65e6b2 | ||
|
|
7325f25b5f | ||
|
|
362b19fd66 | ||
|
|
7f8897d76d | ||
|
|
2bd07d09d3 | ||
|
|
d3446aa428 |
@@ -6,104 +6,44 @@ on:
|
|||||||
- prod
|
- prod
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
services:
|
|
||||||
postgres:
|
|
||||||
image: postgres:15-alpine
|
|
||||||
env:
|
|
||||||
POSTGRES_PASSWORD: postgres
|
|
||||||
POSTGRES_DB: lediscord_test
|
|
||||||
options: >-
|
|
||||||
--health-cmd pg_isready
|
|
||||||
--health-interval 10s
|
|
||||||
--health-timeout 5s
|
|
||||||
--health-retries 5
|
|
||||||
ports:
|
|
||||||
- 5432:5432
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v4
|
|
||||||
with:
|
|
||||||
python-version: '3.11'
|
|
||||||
|
|
||||||
- name: Install backend dependencies
|
|
||||||
run: |
|
|
||||||
cd backend
|
|
||||||
pip install -r requirements.txt
|
|
||||||
|
|
||||||
- name: Run backend tests
|
|
||||||
run: |
|
|
||||||
cd backend
|
|
||||||
python -m pytest tests/ -v || true
|
|
||||||
env:
|
|
||||||
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/lediscord_test
|
|
||||||
JWT_SECRET_KEY: test-secret-key
|
|
||||||
CORS_ORIGINS: http://localhost:3000
|
|
||||||
ADMIN_EMAIL: test@test.com
|
|
||||||
ADMIN_PASSWORD: test123
|
|
||||||
ENVIRONMENT: test
|
|
||||||
|
|
||||||
- name: Set up Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: '18'
|
|
||||||
cache: 'npm'
|
|
||||||
cache-dependency-path: frontend/package-lock.json
|
|
||||||
|
|
||||||
- name: Install frontend dependencies
|
|
||||||
run: |
|
|
||||||
cd frontend
|
|
||||||
npm ci
|
|
||||||
|
|
||||||
- name: Build frontend
|
|
||||||
run: |
|
|
||||||
cd frontend
|
|
||||||
npm run build
|
|
||||||
|
|
||||||
build-and-deploy:
|
build-and-deploy:
|
||||||
needs: test
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: catthehacker/ubuntu:act-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Configure DNS
|
||||||
uses: docker/setup-buildx-action@v2
|
run: |
|
||||||
|
echo "nameserver 192.168.1.50" > /etc/resolv.conf
|
||||||
- name: Login to Gitea Container Registry
|
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
|
||||||
uses: docker/login-action@v2
|
echo "DNS configured:"
|
||||||
with:
|
cat /etc/resolv.conf
|
||||||
registry: ${{ secrets.REGISTRY_URL }}
|
# Ajouter l'IP du registry à /etc/hosts si disponible
|
||||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
if [ -n "${{ secrets.REGISTRY_IP }}" ]; then
|
||||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
echo "${{ secrets.REGISTRY_IP }} ${{ secrets.REGISTRY_URL }}" >> /etc/hosts
|
||||||
|
echo "Added to /etc/hosts: ${{ secrets.REGISTRY_IP }} ${{ secrets.REGISTRY_URL }}"
|
||||||
- name: Build and push backend image
|
fi
|
||||||
uses: docker/build-push-action@v4
|
# Tester la résolution DNS
|
||||||
with:
|
echo "Testing DNS resolution..."
|
||||||
context: ./backend
|
getent hosts ${{ secrets.REGISTRY_URL }} || echo "DNS resolution test"
|
||||||
file: ./backend/Dockerfile
|
|
||||||
push: true
|
- name: Login to Gitea Registry
|
||||||
tags: |
|
run: |
|
||||||
${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord-backend:prod
|
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login ${{ secrets.REGISTRY_URL }} -u ${{ secrets.REGISTRY_USERNAME }} --password-stdin
|
||||||
${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord-backend:latest
|
|
||||||
cache-from: type=registry,ref=${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord-backend:prod
|
- name: Build and push
|
||||||
cache-to: type=inline
|
run: |
|
||||||
|
echo "Building backend image..."
|
||||||
- name: Build and push frontend image
|
docker build -t ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:prod-backend ./backend
|
||||||
uses: docker/build-push-action@v4
|
docker tag ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:prod-backend ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:latest-backend
|
||||||
with:
|
echo "Pushing backend images..."
|
||||||
context: ./frontend
|
docker push ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:prod-backend
|
||||||
file: ./frontend/Dockerfile
|
docker push ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:latest-backend
|
||||||
push: true
|
echo "Building frontend image..."
|
||||||
tags: |
|
docker build -t ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:prod-frontend ./frontend
|
||||||
${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord-frontend:prod
|
docker tag ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:prod-frontend ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:latest-frontend
|
||||||
${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord-frontend:latest
|
echo "Pushing frontend images..."
|
||||||
cache-from: type=registry,ref=${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord-frontend:prod
|
docker push ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:prod-frontend
|
||||||
cache-to: type=inline
|
docker push ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:latest-frontend
|
||||||
Reference in New Issue
Block a user