when: - event: [push, pull_request] steps: # Lint and test frontend frontend-lint: image: node:18-alpine commands: - cd bugulma/frontend - yarn install --frozen-lockfile - yarn lint - yarn test --run when: - event: [push, pull_request] path: "bugulma/frontend/**" # Build and push frontend using Kaniko (containerd-compatible) frontend-build: image: gcr.io/kaniko-project/executor:latest commands: - mkdir -p /kaniko/.docker - echo "{\"auths\":{\"registry.bk.glpx.pro\":{\"username\":\"${DOCKER_USERNAME}\",\"password\":\"${DOCKER_PASSWORD}\"}}}" > /kaniko/.docker/config.json - /kaniko/executor --dockerfile=bugulma/frontend/Dockerfile --context=bugulma/frontend --destination=registry.bk.glpx.pro/turash/turash-frontend:latest --destination=registry.bk.glpx.pro/turash/turash-frontend:${CI_COMMIT_SHA} --cache=true --cache-ttl=168h --compressed-caching=false environment: DOCKER_USERNAME: from_secret: docker_username DOCKER_PASSWORD: from_secret: docker_password when: - event: push branch: master path: "bugulma/frontend/**" # Lint and test backend backend-lint: image: golang:1.21-alpine commands: - cd bugulma/backend - go mod download - go vet ./... - go test -v -race -coverprofile=coverage.out ./... - go tool cover -html=coverage.out -o coverage.html when: - event: [push, pull_request] path: "bugulma/backend/**" # Build and push backend using Kaniko (containerd-compatible) backend-build: image: gcr.io/kaniko-project/executor:latest commands: - mkdir -p /kaniko/.docker - echo "{\"auths\":{\"registry.bk.glpx.pro\":{\"username\":\"${DOCKER_USERNAME}\",\"password\":\"${DOCKER_PASSWORD}\"}}}" > /kaniko/.docker/config.json - /kaniko/executor --dockerfile=bugulma/backend/Dockerfile --context=bugulma/backend --destination=registry.bk.glpx.pro/turash/turash-backend:latest --destination=registry.bk.glpx.pro/turash/turash-backend:${CI_COMMIT_SHA} --cache=true --cache-ttl=168h --compressed-caching=false environment: DOCKER_USERNAME: from_secret: docker_username DOCKER_PASSWORD: from_secret: docker_password when: - event: push branch: master path: "bugulma/backend/**" # Deploy to staging deploy-staging: image: bitnami/kubectl:latest commands: - kubectl config set-cluster k3s --server=https://10.10.10.2:6443 --insecure-skip-tls-verify=true - kubectl config set-credentials default --token=${KUBE_TOKEN} - kubectl config set-context default --cluster=k3s --user=default - kubectl config use-context default # Deploy backend - kubectl apply -f k8s/namespace.yaml - kubectl apply -f k8s/configmap.yaml - kubectl apply -f k8s/secret.yaml - kubectl set image deployment/turash-backend backend=registry.bk.glpx.pro/turash/turash-backend:${CI_COMMIT_SHA} -n turash || kubectl create -f k8s/deployment.yaml - kubectl rollout status deployment/turash-backend -n turash # Deploy frontend - kubectl apply -f k8s/frontend-deployment.yaml - kubectl apply -f k8s/frontend-service.yaml - kubectl set image deployment/turash-frontend frontend=registry.bk.glpx.pro/turash/turash-frontend:${CI_COMMIT_SHA} -n turash - kubectl rollout status deployment/turash-frontend -n turash environment: KUBE_TOKEN: from_secret: kube_token when: - event: push branch: master path: ["bugulma/**", "k8s/**"] # Run E2E tests e2e-test: image: mcr.microsoft.com/playwright:v1.40.0-jammy commands: - cd bugulma/frontend - yarn install --frozen-lockfile - yarn test:e2e --headed=false when: - event: push branch: master path: "bugulma/frontend/**" # Notify on failure notify-failure: image: alpine:latest commands: - echo "Pipeline failed for commit ${CI_COMMIT_SHA}" - echo "Check logs at ${CI_SYSTEM_URL}/${CI_REPO}/${CI_PIPELINE_NUMBER}" when: - event: [push, pull_request] status: failure