128 lines
3.5 KiB
YAML
128 lines
3.5 KiB
YAML
## Universal .drone.yml for all project types
|
|
## Configure your project via service.yaml (see ci-templates/docs/requirements.md)
|
|
|
|
kind: pipeline
|
|
type: kubernetes
|
|
name: ci
|
|
|
|
steps:
|
|
- name: prepare
|
|
image: alpine:3.19
|
|
environment:
|
|
GITEA_TOKEN:
|
|
from_secret: GITEA_TOKEN
|
|
commands:
|
|
- apk add --no-cache git bash yq
|
|
- git clone --depth 1 https://token:$GITEA_TOKEN@git.vigdorov.ru/vigdorov/ci-templates.git .ci
|
|
- chmod +x .ci/scripts/*.sh
|
|
- bash .ci/scripts/prepare.sh
|
|
|
|
- name: build
|
|
image: gcr.io/kaniko-project/executor:v1.23.2-debug
|
|
depends_on: [prepare]
|
|
environment:
|
|
HARBOR_USER:
|
|
from_secret: HARBOR_USER
|
|
HARBOR_PASSWORD:
|
|
from_secret: HARBOR_PASSWORD
|
|
commands:
|
|
- /busybox/sh .ci/scripts/build.sh
|
|
|
|
- name: deploy
|
|
image: alpine:3.19
|
|
depends_on: [build]
|
|
environment:
|
|
KUBE_CONFIG:
|
|
from_secret: KUBE_CONFIG
|
|
commands:
|
|
- apk add --no-cache bash yq kubectl helm
|
|
- bash .ci/scripts/deploy.sh
|
|
|
|
trigger:
|
|
branch: [main, master]
|
|
event: [push]
|
|
|
|
---
|
|
kind: pipeline
|
|
type: kubernetes
|
|
name: keycloak-theme
|
|
|
|
volumes:
|
|
- name: shared
|
|
temp: {}
|
|
|
|
steps:
|
|
- name: check-changes
|
|
image: alpine/git
|
|
volumes:
|
|
- name: shared
|
|
path: /shared
|
|
commands:
|
|
- |
|
|
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD -- keycloak-theme/ 2>/dev/null | grep -v '\.md$' || true)
|
|
if [ -z "$CHANGED_FILES" ]; then
|
|
echo "No changes in keycloak-theme/ - skipping"
|
|
touch /shared/.skip
|
|
else
|
|
echo "Changed files:"
|
|
echo "$CHANGED_FILES"
|
|
fi
|
|
|
|
- name: build-keycloak-theme
|
|
image: gcr.io/kaniko-project/executor:debug
|
|
depends_on: [check-changes]
|
|
volumes:
|
|
- name: shared
|
|
path: /shared
|
|
environment:
|
|
HARBOR_USER:
|
|
from_secret: HARBOR_USER
|
|
HARBOR_PASSWORD:
|
|
from_secret: HARBOR_PASSWORD
|
|
commands:
|
|
- |
|
|
if [ -f /shared/.skip ]; then
|
|
echo "Skipping build"
|
|
exit 0
|
|
fi
|
|
- |
|
|
export IMAGE_TAG=$(echo $DRONE_COMMIT_SHA | cut -c1-7)
|
|
export REGISTRY="registry.vigdorov.ru"
|
|
export REPO="$REGISTRY/library/keycloak-team-planner"
|
|
mkdir -p /kaniko/.docker
|
|
echo "{\"auths\":{\"$REGISTRY\":{\"username\":\"$HARBOR_USER\",\"password\":\"$HARBOR_PASSWORD\"}}}" > /kaniko/.docker/config.json
|
|
/kaniko/executor \
|
|
--dockerfile=keycloak-theme/Dockerfile \
|
|
--context=dir:///drone/src/keycloak-theme \
|
|
--destination=$REPO:$IMAGE_TAG \
|
|
--destination=$REPO:latest \
|
|
--cache=false
|
|
|
|
- name: deploy-keycloak-theme
|
|
image: alpine/k8s:1.28.2
|
|
depends_on: [build-keycloak-theme]
|
|
volumes:
|
|
- name: shared
|
|
path: /shared
|
|
environment:
|
|
KUBE_CONFIG_CONTENT:
|
|
from_secret: KUBE_CONFIG
|
|
commands:
|
|
- |
|
|
if [ -f /shared/.skip ]; then
|
|
echo "Skipping deploy"
|
|
exit 0
|
|
fi
|
|
- |
|
|
mkdir -p ~/.kube
|
|
echo "$KUBE_CONFIG_CONTENT" > ~/.kube/config
|
|
chmod 600 ~/.kube/config
|
|
sed -i "s|https://127.0.0.1:6443|https://10.10.10.100:6443|g" ~/.kube/config
|
|
export IMAGE_TAG=$(echo $DRONE_COMMIT_SHA | cut -c1-7)
|
|
kubectl set image statefulset/keycloak-keycloakx keycloak=registry.vigdorov.ru/library/keycloak-team-planner:$IMAGE_TAG -n auth
|
|
kubectl rollout status statefulset/keycloak-keycloakx -n auth --timeout=180s
|
|
|
|
trigger:
|
|
branch: [main, master]
|
|
event: [push]
|