From d3446aa42885b48893d69d54b075e1fdb6a24fcf Mon Sep 17 00:00:00 2001 From: EvanChal Date: Wed, 24 Dec 2025 03:32:09 +0100 Subject: [PATCH] ci/cd update --- .gitea/workflows/deploy-prod.yml | 115 ++++++------------------------- 1 file changed, 21 insertions(+), 94 deletions(-) diff --git a/.gitea/workflows/deploy-prod.yml b/.gitea/workflows/deploy-prod.yml index df86abf..f1e6350 100644 --- a/.gitea/workflows/deploy-prod.yml +++ b/.gitea/workflows/deploy-prod.yml @@ -6,104 +6,31 @@ on: - prod 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: needs: test runs-on: ubuntu-latest - + container: + image: catthehacker/ubuntu:act-latest steps: - name: Checkout code uses: actions/checkout@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to Gitea Container Registry - uses: docker/login-action@v2 - with: - registry: ${{ secrets.REGISTRY_URL }} - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_TOKEN }} - - - name: Build and push backend image - uses: docker/build-push-action@v4 - with: - context: ./backend - file: ./backend/Dockerfile - push: true - tags: | - ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord-backend:prod - ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord-backend:latest - cache-from: type=registry,ref=${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord-backend:prod - cache-to: type=inline - - - name: Build and push frontend image - uses: docker/build-push-action@v4 - with: - context: ./frontend - file: ./frontend/Dockerfile - push: true - tags: | - ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord-frontend:prod - ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord-frontend:latest - cache-from: type=registry,ref=${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord-frontend:prod - cache-to: type=inline \ No newline at end of file + + - name: Login to Gitea Registry + run: | + echo "${{ secrets.REGISTRY_TOKEN }}" | docker login ${{ secrets.REGISTRY_URL }} -u ${{ secrets.REGISTRY_USERNAME }} --password-stdin + + - name: Build and push + run: | + echo "Building backend image..." + docker build -t ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:prod-backend ./backend + docker tag ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:prod-backend ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:latest-backend + echo "Pushing backend images..." + docker push ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:prod-backend + docker push ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:latest-backend + echo "Building frontend image..." + docker build -t ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:prod-frontend ./frontend + docker tag ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:prod-frontend ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:latest-frontend + echo "Pushing frontend images..." + docker push ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:prod-frontend + docker push ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:latest-frontend \ No newline at end of file