- Create PVC for shared npm cache across CI jobs - Configure Woodpecker agent to allow npm-cache volume mount - Update typecheck steps to use shared cache directory - First run populates cache, subsequent runs are ~3-4x faster 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
192 lines
6.9 KiB
YAML
192 lines
6.9 KiB
YAML
steps:
|
|
# ===========================================
|
|
# PR VALIDATION: Only typecheck changed projects
|
|
# ===========================================
|
|
typecheck-backend:
|
|
image: code.cannabrands.app/creationshop/node:20
|
|
commands:
|
|
- npm config set cache /npm-cache/backend --global
|
|
- cd backend
|
|
- npm ci --prefer-offline
|
|
- npx tsc --noEmit
|
|
volumes:
|
|
- npm-cache:/npm-cache
|
|
depends_on: []
|
|
when:
|
|
event: pull_request
|
|
path:
|
|
include: ['backend/**']
|
|
|
|
typecheck-cannaiq:
|
|
image: code.cannabrands.app/creationshop/node:20
|
|
commands:
|
|
- npm config set cache /npm-cache/cannaiq --global
|
|
- cd cannaiq
|
|
- npm ci --prefer-offline
|
|
- npx tsc --noEmit
|
|
volumes:
|
|
- npm-cache:/npm-cache
|
|
depends_on: []
|
|
when:
|
|
event: pull_request
|
|
path:
|
|
include: ['cannaiq/**']
|
|
|
|
# findadispo/findagram typechecks skipped - they have || true anyway
|
|
|
|
# ===========================================
|
|
# 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://code.cannabrands.app/api/v1/repos/Creationshop/dispensary-scraper/pulls/${CI_COMMIT_PULL_REQUEST}/merge"
|
|
depends_on:
|
|
- typecheck-backend
|
|
- typecheck-cannaiq
|
|
when:
|
|
event: pull_request
|
|
|
|
# ===========================================
|
|
# MASTER DEPLOY: Parallel Docker builds
|
|
# ===========================================
|
|
docker-backend:
|
|
image: woodpeckerci/plugin-docker-buildx
|
|
settings:
|
|
registry: code.cannabrands.app
|
|
repo: code.cannabrands.app/creationshop/dispensary-scraper
|
|
tags:
|
|
- latest
|
|
- ${CI_COMMIT_SHA:0:8}
|
|
dockerfile: backend/Dockerfile
|
|
context: backend
|
|
username:
|
|
from_secret: registry_username
|
|
password:
|
|
from_secret: registry_password
|
|
platforms: linux/amd64
|
|
provenance: false
|
|
cache_from: type=registry,ref=code.cannabrands.app/creationshop/dispensary-scraper:cache
|
|
cache_to: type=registry,ref=code.cannabrands.app/creationshop/dispensary-scraper:cache,mode=max
|
|
build_args:
|
|
APP_BUILD_VERSION: ${CI_COMMIT_SHA:0:8}
|
|
APP_GIT_SHA: ${CI_COMMIT_SHA}
|
|
APP_BUILD_TIME: ${CI_PIPELINE_CREATED}
|
|
CONTAINER_IMAGE_TAG: ${CI_COMMIT_SHA:0:8}
|
|
depends_on: []
|
|
when:
|
|
branch: master
|
|
event: push
|
|
|
|
docker-cannaiq:
|
|
image: woodpeckerci/plugin-docker-buildx
|
|
settings:
|
|
registry: code.cannabrands.app
|
|
repo: code.cannabrands.app/creationshop/cannaiq-frontend
|
|
tags:
|
|
- latest
|
|
- ${CI_COMMIT_SHA:0:8}
|
|
dockerfile: cannaiq/Dockerfile
|
|
context: cannaiq
|
|
username:
|
|
from_secret: registry_username
|
|
password:
|
|
from_secret: registry_password
|
|
platforms: linux/amd64
|
|
provenance: false
|
|
cache_from: type=registry,ref=code.cannabrands.app/creationshop/cannaiq-frontend:cache
|
|
cache_to: type=registry,ref=code.cannabrands.app/creationshop/cannaiq-frontend:cache,mode=max
|
|
depends_on: []
|
|
when:
|
|
branch: master
|
|
event: push
|
|
|
|
docker-findadispo:
|
|
image: woodpeckerci/plugin-docker-buildx
|
|
settings:
|
|
registry: code.cannabrands.app
|
|
repo: code.cannabrands.app/creationshop/findadispo-frontend
|
|
tags:
|
|
- latest
|
|
- ${CI_COMMIT_SHA:0:8}
|
|
dockerfile: findadispo/frontend/Dockerfile
|
|
context: findadispo/frontend
|
|
username:
|
|
from_secret: registry_username
|
|
password:
|
|
from_secret: registry_password
|
|
platforms: linux/amd64
|
|
provenance: false
|
|
cache_from: type=registry,ref=code.cannabrands.app/creationshop/findadispo-frontend:cache
|
|
cache_to: type=registry,ref=code.cannabrands.app/creationshop/findadispo-frontend:cache,mode=max
|
|
depends_on: []
|
|
when:
|
|
branch: master
|
|
event: push
|
|
|
|
docker-findagram:
|
|
image: woodpeckerci/plugin-docker-buildx
|
|
settings:
|
|
registry: code.cannabrands.app
|
|
repo: code.cannabrands.app/creationshop/findagram-frontend
|
|
tags:
|
|
- latest
|
|
- ${CI_COMMIT_SHA:0:8}
|
|
dockerfile: findagram/frontend/Dockerfile
|
|
context: findagram/frontend
|
|
username:
|
|
from_secret: registry_username
|
|
password:
|
|
from_secret: registry_password
|
|
platforms: linux/amd64
|
|
provenance: false
|
|
cache_from: type=registry,ref=code.cannabrands.app/creationshop/findagram-frontend:cache
|
|
cache_to: type=registry,ref=code.cannabrands.app/creationshop/findagram-frontend:cache,mode=max
|
|
depends_on: []
|
|
when:
|
|
branch: master
|
|
event: push
|
|
|
|
# ===========================================
|
|
# STAGE 3: Deploy and Run Migrations
|
|
# ===========================================
|
|
deploy:
|
|
image: bitnami/kubectl:latest
|
|
environment:
|
|
KUBECONFIG_CONTENT:
|
|
from_secret: kubeconfig_data
|
|
commands:
|
|
- mkdir -p ~/.kube
|
|
- echo "$KUBECONFIG_CONTENT" | tr -d '[:space:]' | base64 -d > ~/.kube/config
|
|
- chmod 600 ~/.kube/config
|
|
# Deploy backend first
|
|
- kubectl set image deployment/scraper scraper=code.cannabrands.app/creationshop/dispensary-scraper:${CI_COMMIT_SHA:0:8} -n dispensary-scraper
|
|
- kubectl rollout status deployment/scraper -n dispensary-scraper --timeout=300s
|
|
# Note: Migrations run automatically at startup via auto-migrate
|
|
# Deploy remaining services
|
|
# Resilience: ensure workers are scaled up if at 0
|
|
- REPLICAS=$(kubectl get deployment scraper-worker -n dispensary-scraper -o jsonpath='{.spec.replicas}'); if [ "$REPLICAS" = "0" ]; then echo "Scaling workers from 0 to 5"; kubectl scale deployment/scraper-worker --replicas=5 -n dispensary-scraper; fi
|
|
- kubectl set image deployment/scraper-worker worker=code.cannabrands.app/creationshop/dispensary-scraper:${CI_COMMIT_SHA:0:8} -n dispensary-scraper
|
|
- kubectl set image deployment/cannaiq-frontend cannaiq-frontend=code.cannabrands.app/creationshop/cannaiq-frontend:${CI_COMMIT_SHA:0:8} -n dispensary-scraper
|
|
- kubectl set image deployment/findadispo-frontend findadispo-frontend=code.cannabrands.app/creationshop/findadispo-frontend:${CI_COMMIT_SHA:0:8} -n dispensary-scraper
|
|
- kubectl set image deployment/findagram-frontend findagram-frontend=code.cannabrands.app/creationshop/findagram-frontend:${CI_COMMIT_SHA:0:8} -n dispensary-scraper
|
|
- kubectl rollout status deployment/cannaiq-frontend -n dispensary-scraper --timeout=120s
|
|
depends_on:
|
|
- docker-backend
|
|
- docker-cannaiq
|
|
- docker-findadispo
|
|
- docker-findagram
|
|
when:
|
|
branch: master
|
|
event: push
|