steps: # =========================================== # PR VALIDATION: Parallel type checks (PRs only) # =========================================== typecheck-backend: image: node:22 commands: - cd backend - npm ci --prefer-offline - npx tsc --noEmit depends_on: [] when: event: pull_request typecheck-cannaiq: image: node:22 commands: - cd cannaiq - npm ci --prefer-offline - npx tsc --noEmit depends_on: [] when: event: pull_request typecheck-findadispo: image: node:22 commands: - cd findadispo/frontend - npm ci --prefer-offline - npx tsc --noEmit 2>/dev/null || true depends_on: [] when: event: pull_request typecheck-findagram: image: node:22 commands: - cd findagram/frontend - npm ci --prefer-offline - npx tsc --noEmit 2>/dev/null || true depends_on: [] when: event: pull_request # =========================================== # AUTO-MERGE: Merge PR after all checks pass # =========================================== auto-merge: image: alpine:latest environment: GITEA_TOKEN: from_secret: gitea_token commands: - apk add --no-cache curl - | echo "Merging PR #${CI_COMMIT_PULL_REQUEST}..." curl -s -X POST \ -H "Authorization: token $GITEA_TOKEN" \ -H "Content-Type: application/json" \ -d '{"Do":"merge"}' \ "https://git.spdy.io/api/v1/repos/Creationshop/cannaiq/pulls/${CI_COMMIT_PULL_REQUEST}/merge" depends_on: - typecheck-backend - typecheck-cannaiq - typecheck-findadispo - typecheck-findagram when: event: pull_request # =========================================== # DOCKER: Multi-stage builds with layer caching # =========================================== docker-backend: image: gcr.io/kaniko-project/executor:debug commands: - /kaniko/executor --context=/woodpecker/src/git.spdy.io/Creationshop/cannaiq/backend --dockerfile=/woodpecker/src/git.spdy.io/Creationshop/cannaiq/backend/Dockerfile --destination=registry.spdy.io/cannaiq/backend:latest --destination=registry.spdy.io/cannaiq/backend:sha-${CI_COMMIT_SHA:0:8} --build-arg=APP_BUILD_VERSION=sha-${CI_COMMIT_SHA:0:8} --build-arg=APP_GIT_SHA=${CI_COMMIT_SHA} --build-arg=APP_BUILD_TIME=${CI_PIPELINE_CREATED} --cache=true --cache-repo=registry.spdy.io/cannaiq/cache-backend --cache-ttl=168h depends_on: [] when: branch: [master, develop] event: push docker-cannaiq: image: gcr.io/kaniko-project/executor:debug commands: - /kaniko/executor --context=/woodpecker/src/git.spdy.io/Creationshop/cannaiq/cannaiq --dockerfile=/woodpecker/src/git.spdy.io/Creationshop/cannaiq/cannaiq/Dockerfile --destination=registry.spdy.io/cannaiq/frontend:latest --destination=registry.spdy.io/cannaiq/frontend:sha-${CI_COMMIT_SHA:0:8} --cache=true --cache-repo=registry.spdy.io/cannaiq/cache-cannaiq --cache-ttl=168h depends_on: [] when: branch: [master, develop] event: push docker-findadispo: image: gcr.io/kaniko-project/executor:debug commands: - /kaniko/executor --context=/woodpecker/src/git.spdy.io/Creationshop/cannaiq/findadispo/frontend --dockerfile=/woodpecker/src/git.spdy.io/Creationshop/cannaiq/findadispo/frontend/Dockerfile --destination=registry.spdy.io/cannaiq/findadispo:latest --destination=registry.spdy.io/cannaiq/findadispo:sha-${CI_COMMIT_SHA:0:8} --cache=true --cache-repo=registry.spdy.io/cannaiq/cache-findadispo --cache-ttl=168h depends_on: [] when: branch: [master, develop] event: push docker-findagram: image: gcr.io/kaniko-project/executor:debug commands: - /kaniko/executor --context=/woodpecker/src/git.spdy.io/Creationshop/cannaiq/findagram/frontend --dockerfile=/woodpecker/src/git.spdy.io/Creationshop/cannaiq/findagram/frontend/Dockerfile --destination=registry.spdy.io/cannaiq/findagram:latest --destination=registry.spdy.io/cannaiq/findagram:sha-${CI_COMMIT_SHA:0:8} --cache=true --cache-repo=registry.spdy.io/cannaiq/cache-findagram --cache-ttl=168h depends_on: [] when: branch: [master, develop] event: push # =========================================== # DEPLOY: Pull from local registry # =========================================== deploy: image: bitnami/kubectl:latest environment: K8S_TOKEN: from_secret: k8s_token commands: - mkdir -p ~/.kube - | cat > ~/.kube/config << KUBEEOF apiVersion: v1 kind: Config clusters: - cluster: certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJkakNDQVIyZ0F3SUJBZ0lCQURBS0JnZ3Foa2pPUFFRREFqQWpNU0V3SHdZRFZRUUREQmhyTTNNdGMyVnkKZG1WeUxXTmhRREUzTmpVM05UUTNPRE13SGhjTk1qVXhNakUwTWpNeU5qSXpXaGNOTXpVeE1qRXlNak15TmpJegpXakFqTVNFd0h3WURWUVFEREJock0zTXRjMlZ5ZG1WeUxXTmhRREUzTmpVM05UUTNPRE13V1RBVEJnY3Foa2pPClBRSUJCZ2dxaGtqT1BRTUJCd05DQUFRWDRNdFJRTW5lWVJVV0s2cjZ3VEV2WjAxNnV4T3NUR3JJZ013TXVnNGwKajQ1bHZ6ZkM1WE1NY1pESnUxZ0t1dVJhVGxlb0xVOVJnSERIUUI4TUwzNTJvMEl3UURBT0JnTlZIUThCQWY4RQpCQU1DQXFRd0R3WURWUjBUQVFIL0JBVXdBd0VCL3pBZEJnTlZIUTRFRmdRVXIzNDZpNE42TFhzaEZsREhvSlU0CjJ1RjZseGN3Q2dZSUtvWkl6ajBFQXdJRFJ3QXdSQUlnVUtqdWRFQWJyS1JDVHROVXZTc1Rmb3FEaHFSeDM5MkYKTFFSVWlKK0hCVElDSUJqOFIxbG1zSnFSRkRHMEpwMGN4OG5ZZnFCaElRQzh6WWdRdTdBZmR4L3IKLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo= server: https://10.100.6.10:6443 name: spdy-k3s contexts: - context: cluster: spdy-k3s namespace: cannaiq user: cannaiq-admin name: cannaiq current-context: cannaiq users: - name: cannaiq-admin user: token: $K8S_TOKEN KUBEEOF - chmod 600 ~/.kube/config # Apply manifests to ensure probes and resource limits are set - kubectl apply -f /woodpecker/src/git.spdy.io/Creationshop/cannaiq/k8s/scraper.yaml - kubectl set image deployment/scraper scraper=registry.spdy.io/cannaiq/backend:sha-${CI_COMMIT_SHA:0:8} -n cannaiq - kubectl rollout status deployment/scraper -n cannaiq --timeout=300s - REPLICAS=$(kubectl get deployment scraper-worker -n cannaiq -o jsonpath='{.spec.replicas}'); if [ "$REPLICAS" = "0" ]; then kubectl scale deployment/scraper-worker --replicas=5 -n cannaiq; fi - kubectl set image deployment/scraper-worker worker=registry.spdy.io/cannaiq/backend:sha-${CI_COMMIT_SHA:0:8} -n cannaiq - kubectl set image deployment/cannaiq-frontend cannaiq-frontend=registry.spdy.io/cannaiq/frontend:sha-${CI_COMMIT_SHA:0:8} -n cannaiq - kubectl set image deployment/findadispo-frontend findadispo-frontend=registry.spdy.io/cannaiq/findadispo:sha-${CI_COMMIT_SHA:0:8} -n cannaiq - kubectl set image deployment/findagram-frontend findagram-frontend=registry.spdy.io/cannaiq/findagram:sha-${CI_COMMIT_SHA:0:8} -n cannaiq - kubectl rollout status deployment/cannaiq-frontend -n cannaiq --timeout=300s depends_on: - docker-backend - docker-cannaiq - docker-findadispo - docker-findagram when: branch: [master, develop] event: push