All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Tagging Strategy:
- main branch: {sha} + 'latest'
- develop branch: {sha} + 'dev'
- git tags: {sha} + version (e.g., v1.0.0)
Also added docs/harbor-tag-retention-policy.md with:
- Recommended retention rules for Harbor
- Garbage collection schedule
- Cleanup commands and scripts
- Monitoring commands
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
186 lines
5.6 KiB
YAML
186 lines
5.6 KiB
YAML
# Woodpecker CI Quality Enforcement Pipeline - Monorepo
|
|
when:
|
|
- event: [push, pull_request, manual]
|
|
|
|
variables:
|
|
- &node_image "node:20-alpine"
|
|
- &install_deps |
|
|
corepack enable
|
|
pnpm install --frozen-lockfile
|
|
- &use_deps |
|
|
corepack enable
|
|
# Kaniko base command setup
|
|
- &kaniko_setup |
|
|
mkdir -p /kaniko/.docker
|
|
echo "{\"auths\":{\"reg.mosaicstack.dev\":{\"username\":\"$HARBOR_USER\",\"password\":\"$HARBOR_PASS\"}}}" > /kaniko/.docker/config.json
|
|
|
|
steps:
|
|
install:
|
|
image: *node_image
|
|
commands:
|
|
- *install_deps
|
|
|
|
security-audit:
|
|
image: *node_image
|
|
commands:
|
|
- *use_deps
|
|
- pnpm audit --audit-level=high
|
|
depends_on:
|
|
- install
|
|
|
|
lint:
|
|
image: *node_image
|
|
environment:
|
|
SKIP_ENV_VALIDATION: "true"
|
|
commands:
|
|
- *use_deps
|
|
- pnpm lint || true # Non-blocking while fixing legacy code
|
|
depends_on:
|
|
- install
|
|
when:
|
|
- evaluate: 'CI_PIPELINE_EVENT != "pull_request" || CI_COMMIT_BRANCH != "main"'
|
|
|
|
prisma-generate:
|
|
image: *node_image
|
|
environment:
|
|
SKIP_ENV_VALIDATION: "true"
|
|
commands:
|
|
- *use_deps
|
|
- pnpm --filter "@mosaic/api" prisma:generate
|
|
depends_on:
|
|
- install
|
|
|
|
typecheck:
|
|
image: *node_image
|
|
environment:
|
|
SKIP_ENV_VALIDATION: "true"
|
|
commands:
|
|
- *use_deps
|
|
- pnpm typecheck
|
|
depends_on:
|
|
- prisma-generate
|
|
|
|
test:
|
|
image: *node_image
|
|
environment:
|
|
SKIP_ENV_VALIDATION: "true"
|
|
commands:
|
|
- *use_deps
|
|
- pnpm test || true # Non-blocking while fixing legacy tests
|
|
depends_on:
|
|
- prisma-generate
|
|
|
|
build:
|
|
image: *node_image
|
|
environment:
|
|
SKIP_ENV_VALIDATION: "true"
|
|
NODE_ENV: "production"
|
|
commands:
|
|
- *use_deps
|
|
- pnpm build
|
|
depends_on:
|
|
- typecheck # Only block on critical checks
|
|
- security-audit
|
|
- prisma-generate
|
|
|
|
# ======================
|
|
# Docker Build & Push (main/develop only)
|
|
# ======================
|
|
# Requires secrets: harbor_username, harbor_password
|
|
#
|
|
# Tagging Strategy:
|
|
# - Always: commit SHA (e.g., 658ec077)
|
|
# - main branch: 'latest'
|
|
# - develop branch: 'dev'
|
|
# - git tags: version tag (e.g., v1.0.0)
|
|
|
|
# Build and push API image using Kaniko
|
|
docker-build-api:
|
|
image: gcr.io/kaniko-project/executor:debug
|
|
environment:
|
|
HARBOR_USER:
|
|
from_secret: harbor_username
|
|
HARBOR_PASS:
|
|
from_secret: harbor_password
|
|
CI_COMMIT_BRANCH: ${CI_COMMIT_BRANCH}
|
|
CI_COMMIT_TAG: ${CI_COMMIT_TAG}
|
|
CI_COMMIT_SHA: ${CI_COMMIT_SHA}
|
|
commands:
|
|
- *kaniko_setup
|
|
- |
|
|
DESTINATIONS="--destination reg.mosaicstack.dev/mosaic/api:${CI_COMMIT_SHA:0:8}"
|
|
if [ "$CI_COMMIT_BRANCH" = "main" ]; then
|
|
DESTINATIONS="$DESTINATIONS --destination reg.mosaicstack.dev/mosaic/api:latest"
|
|
elif [ "$CI_COMMIT_BRANCH" = "develop" ]; then
|
|
DESTINATIONS="$DESTINATIONS --destination reg.mosaicstack.dev/mosaic/api:dev"
|
|
fi
|
|
if [ -n "$CI_COMMIT_TAG" ]; then
|
|
DESTINATIONS="$DESTINATIONS --destination reg.mosaicstack.dev/mosaic/api:$CI_COMMIT_TAG"
|
|
fi
|
|
/kaniko/executor --context . --dockerfile apps/api/Dockerfile $DESTINATIONS
|
|
when:
|
|
- branch: [main, develop]
|
|
event: [push, manual, tag]
|
|
depends_on:
|
|
- build
|
|
|
|
# Build and push Web image using Kaniko
|
|
docker-build-web:
|
|
image: gcr.io/kaniko-project/executor:debug
|
|
environment:
|
|
HARBOR_USER:
|
|
from_secret: harbor_username
|
|
HARBOR_PASS:
|
|
from_secret: harbor_password
|
|
CI_COMMIT_BRANCH: ${CI_COMMIT_BRANCH}
|
|
CI_COMMIT_TAG: ${CI_COMMIT_TAG}
|
|
CI_COMMIT_SHA: ${CI_COMMIT_SHA}
|
|
commands:
|
|
- *kaniko_setup
|
|
- |
|
|
DESTINATIONS="--destination reg.mosaicstack.dev/mosaic/web:${CI_COMMIT_SHA:0:8}"
|
|
if [ "$CI_COMMIT_BRANCH" = "main" ]; then
|
|
DESTINATIONS="$DESTINATIONS --destination reg.mosaicstack.dev/mosaic/web:latest"
|
|
elif [ "$CI_COMMIT_BRANCH" = "develop" ]; then
|
|
DESTINATIONS="$DESTINATIONS --destination reg.mosaicstack.dev/mosaic/web:dev"
|
|
fi
|
|
if [ -n "$CI_COMMIT_TAG" ]; then
|
|
DESTINATIONS="$DESTINATIONS --destination reg.mosaicstack.dev/mosaic/web:$CI_COMMIT_TAG"
|
|
fi
|
|
/kaniko/executor --context . --dockerfile apps/web/Dockerfile --build-arg NEXT_PUBLIC_API_URL=https://api.mosaicstack.dev $DESTINATIONS
|
|
when:
|
|
- branch: [main, develop]
|
|
event: [push, manual, tag]
|
|
depends_on:
|
|
- build
|
|
|
|
# Build and push Postgres image using Kaniko
|
|
docker-build-postgres:
|
|
image: gcr.io/kaniko-project/executor:debug
|
|
environment:
|
|
HARBOR_USER:
|
|
from_secret: harbor_username
|
|
HARBOR_PASS:
|
|
from_secret: harbor_password
|
|
CI_COMMIT_BRANCH: ${CI_COMMIT_BRANCH}
|
|
CI_COMMIT_TAG: ${CI_COMMIT_TAG}
|
|
CI_COMMIT_SHA: ${CI_COMMIT_SHA}
|
|
commands:
|
|
- *kaniko_setup
|
|
- |
|
|
DESTINATIONS="--destination reg.mosaicstack.dev/mosaic/postgres:${CI_COMMIT_SHA:0:8}"
|
|
if [ "$CI_COMMIT_BRANCH" = "main" ]; then
|
|
DESTINATIONS="$DESTINATIONS --destination reg.mosaicstack.dev/mosaic/postgres:latest"
|
|
elif [ "$CI_COMMIT_BRANCH" = "develop" ]; then
|
|
DESTINATIONS="$DESTINATIONS --destination reg.mosaicstack.dev/mosaic/postgres:dev"
|
|
fi
|
|
if [ -n "$CI_COMMIT_TAG" ]; then
|
|
DESTINATIONS="$DESTINATIONS --destination reg.mosaicstack.dev/mosaic/postgres:$CI_COMMIT_TAG"
|
|
fi
|
|
/kaniko/executor --context docker/postgres --dockerfile docker/postgres/Dockerfile $DESTINATIONS
|
|
when:
|
|
- branch: [main, develop]
|
|
event: [push, manual, tag]
|
|
depends_on:
|
|
- build
|