Changeset a8fe58e


Ignore:
Timestamp:
06/23/26 13:23:01 (2 weeks ago)
Author:
Andrej <asumanovski@…>
Branches:
master
Children:
52fee06
Parents:
c0086c0
Message:

Simplify pipeline to CI only — build and push to DockerHub, no deployment

File:
1 edited

Legend:

Unmodified
Added
Removed
  • .github/workflows/ci-cd.yml

    rc0086c0 ra8fe58e  
    1 name: CI/CD
     1name: CI
    22
    33on:
    44  push:
    5     branches: [master]
     5    branches: [master, dev]
    66  pull_request:
    77    branches: [master]
     
    1212
    1313jobs:
    14   # ── CI: build both images on every push / PR ──────────────────────────────
    1514  build:
    1615    name: Build
     
    2221        uses: docker/setup-buildx-action@v3
    2322
    24       - name: Build backend image (no push)
     23      - name: Build backend image
    2524        uses: docker/build-push-action@v5
    2625        with:
     
    3029          cache-to:   type=gha,scope=backend,mode=max
    3130
    32       - name: Build frontend image (no push)
     31      - name: Build frontend image
    3332        uses: docker/build-push-action@v5
    3433        with:
     
    3837          cache-to:   type=gha,scope=frontend,mode=max
    3938
    40   # ── CD part 1: push images to DockerHub (master only) ─────────────────────
    4139  push:
    4240    name: Push to DockerHub
     
    4442    needs: build
    4543    if: github.ref == 'refs/heads/master' && github.event_name == 'push'
    46     outputs:
    47       image_tag: ${{ github.sha }}
    4844    steps:
    4945      - uses: actions/checkout@v4
     
    7975          cache-from: type=gha,scope=frontend
    8076          cache-to:   type=gha,scope=frontend,mode=max
    81 
    82   # ── CD part 2: deploy to k3s cluster ──────────────────────────────────────
    83   deploy:
    84     name: Deploy to Kubernetes
    85     runs-on: ubuntu-latest
    86     needs: push
    87     steps:
    88       - uses: actions/checkout@v4
    89 
    90       - name: Set up kubectl
    91         uses: azure/setup-kubectl@v3
    92         with:
    93           version: latest
    94 
    95       - name: Configure kubeconfig
    96         run: |
    97           echo "${{ secrets.KUBECONFIG_B64 }}" | base64 -d > $HOME/kubeconfig.yaml
    98           chmod 600 $HOME/kubeconfig.yaml
    99           echo "KUBECONFIG=$HOME/kubeconfig.yaml" >> $GITHUB_ENV
    100 
    101       - name: Apply namespace
    102         run: kubectl apply -f k8s/namespace.yaml
    103 
    104       - name: Create / update app secrets
    105         run: |
    106           kubectl create secret generic trekr-secrets \
    107             --namespace=trekr \
    108             --from-literal=db-password=${{ secrets.DB_PASSWORD }} \
    109             --from-literal=jwt-secret=${{ secrets.JWT_SECRET }} \
    110             --save-config \
    111             --dry-run=client -o yaml | kubectl apply -f -
    112 
    113       - name: Create DB init ConfigMap from DDL
    114         run: |
    115           kubectl create configmap trekr-db-init \
    116             --namespace=trekr \
    117             --from-file=01-ddl.sql=db-scripts/ddl.sql \
    118             --save-config \
    119             --dry-run=client -o yaml | kubectl apply -f -
    120 
    121       - name: Apply Postgres manifests
    122         run: kubectl apply -f k8s/postgres.yaml
    123 
    124       - name: Wait for Postgres to be ready
    125         run: kubectl rollout status statefulset/postgres -n trekr --timeout=120s
    126 
    127       - name: Apply backend manifests
    128         run: kubectl apply -f k8s/backend.yaml
    129 
    130       - name: Apply frontend manifests
    131         run: kubectl apply -f k8s/frontend.yaml
    132 
    133       - name: Roll out new images
    134         run: |
    135           kubectl set image deployment/backend \
    136             backend=${{ env.BACKEND_IMAGE }}:${{ github.sha }} \
    137             -n trekr
    138           kubectl set image deployment/frontend \
    139             frontend=${{ env.FRONTEND_IMAGE }}:${{ github.sha }} \
    140             -n trekr
    141 
    142       - name: Wait for rollout to complete
    143         run: |
    144           kubectl rollout status deployment/backend  -n trekr --timeout=180s
    145           kubectl rollout status deployment/frontend -n trekr --timeout=60s
    146 
    147       - name: Print app URL
    148         run: |
    149           NODE_IP=$(kubectl get nodes -o jsonpath='{.items[0].status.addresses[?(@.type=="ExternalIP")].address}' 2>/dev/null || \
    150                     kubectl get nodes -o jsonpath='{.items[0].status.addresses[0].address}')
    151           echo "App available at: http://${NODE_IP}:30080"
Note: See TracChangeset for help on using the changeset viewer.