turash/.woodpecker.yml

132 lines
3.8 KiB
YAML

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
frontend-build:
image: woodpeckerci/plugin-docker-buildx:latest
privileged: true
settings:
registry: registry.bk.glpx.pro
repo: registry.bk.glpx.pro/turash/turash-frontend
dockerfile: bugulma/frontend/Dockerfile
context: bugulma/frontend
platforms: linux/amd64,linux/arm64
build_args:
- BUILDKIT_PROGRESS=plain
- DOCKER_BUILDKIT=1
tags:
- latest
- ${CI_COMMIT_SHA}
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
backend-build:
image: woodpeckerci/plugin-docker-buildx:latest
privileged: true
settings:
registry: registry.bk.glpx.pro
repo: registry.bk.glpx.pro/turash/turash-backend
dockerfile: bugulma/backend/Dockerfile
context: bugulma/backend
platforms: linux/amd64,linux/arm64
build_args:
- BUILDKIT_PROGRESS=plain
- DOCKER_BUILDKIT=1
tags:
- latest
- ${CI_COMMIT_SHA}
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: 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} -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