when: - event: [push, pull_request] - path: ["bugulma/frontend/**", ".woodpecker.yml"] variables: - &build_args "BUILDKIT_PROGRESS=plain,DOCKER_BUILDKIT=1" - &harbor_registry "registry.bk.glpx.pro" 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: path: "bugulma/frontend/**" # Build and push frontend frontend-build: image: woodpeckerci/plugin-docker-buildx:latest settings: registry: *harbor_registry repo: *harbor_registry/turash/turash-frontend dockerfile: bugulma/frontend/Dockerfile context: bugulma/frontend platforms: linux/amd64,linux/arm64 build_args: *build_args tags: - latest - ${CI_COMMIT_SHA} secrets: [docker_username, 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: path: "bugulma/backend/**" # Build and push backend backend-build: image: woodpeckerci/plugin-docker-buildx:latest settings: registry: *harbor_registry repo: *harbor_registry/turash/turash-backend dockerfile: bugulma/backend/Dockerfile context: bugulma/backend platforms: linux/amd64,linux/arm64 build_args: *build_args tags: - latest - ${CI_COMMIT_SHA} secrets: [docker_username, docker_password] when: event: push branch: master path: "bugulma/backend/**" # Deploy to staging deploy-staging: image: woodpeckerci/plugin-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} - 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} - kubectl rollout status deployment/turash-frontend -n turash secrets: [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: status: failure