2023-02-17 14:19:49 +00:00
|
|
|
---
|
2023-02-17 14:48:16 +00:00
|
|
|
# ----------------------------------------------
|
2023-03-06 20:42:35 +00:00
|
|
|
# -- Update the helm chart
|
|
|
|
# ----------------------------------------------
|
|
|
|
kind: pipeline
|
|
|
|
type: kubernetes
|
|
|
|
name: Publish the helm chart
|
|
|
|
|
|
|
|
trigger:
|
|
|
|
event:
|
|
|
|
- push
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Publish the Helm chart
|
|
|
|
image: alpine/helm
|
|
|
|
environment:
|
|
|
|
GITEA_TOKEN:
|
|
|
|
from_secret: GITEA_TOKEN
|
|
|
|
commands:
|
|
|
|
- helm plugin install https://github.com/chartmuseum/helm-push
|
|
|
|
- helm package chart -d chart-package
|
|
|
|
- helm repo add --username allanger --password $GITEA_TOKEN badhouseplants-net https://git.badhouseplants.net/api/packages/badhouseplants/helm
|
|
|
|
- helm cm-push "./chart-package/$(ls chart-package)" badhouseplants-net
|
|
|
|
---
|
|
|
|
# ----------------------------------------------
|
2023-02-17 14:48:16 +00:00
|
|
|
# -- Build the site and push it to the registry
|
|
|
|
# ----------------------------------------------
|
2023-02-17 14:19:49 +00:00
|
|
|
kind: pipeline
|
|
|
|
type: kubernetes
|
|
|
|
name: Build badhouseplants.net
|
|
|
|
|
2023-02-17 14:48:16 +00:00
|
|
|
trigger:
|
|
|
|
event:
|
2023-03-06 20:42:35 +00:00
|
|
|
- push
|
2023-04-24 16:01:13 +00:00
|
|
|
clone:
|
|
|
|
disable: true
|
2023-02-17 14:48:16 +00:00
|
|
|
|
2023-02-17 14:19:49 +00:00
|
|
|
steps:
|
2023-04-24 16:01:13 +00:00
|
|
|
- name: clone
|
2023-03-06 20:42:35 +00:00
|
|
|
image: alpine/git
|
2023-04-24 16:01:13 +00:00
|
|
|
environment:
|
|
|
|
GIT_LFS_SKIP_SMUDGE: 1
|
2023-03-06 20:42:35 +00:00
|
|
|
commands:
|
2023-04-24 16:01:13 +00:00
|
|
|
- git clone $DRONE_REMOTE_URL --recurse-submodules .
|
|
|
|
- git checkout $DRONE_COMMIT
|
2023-03-06 20:42:35 +00:00
|
|
|
|
|
|
|
- name: Test a build
|
|
|
|
image: git.badhouseplants.net/badhouseplants/hugo-builder
|
2023-04-24 16:01:13 +00:00
|
|
|
depends_on:
|
|
|
|
- clone
|
2023-03-06 20:42:35 +00:00
|
|
|
commands:
|
|
|
|
- hugo
|
2023-04-24 16:01:13 +00:00
|
|
|
|
2023-03-06 20:42:35 +00:00
|
|
|
- name: Build and push the docker image
|
2023-04-24 16:01:13 +00:00
|
|
|
image: git.badhouseplants.net/badhouseplants/badhouseplants-builder:80ffd53372652576fa3c36a56b351b448a025c6a
|
|
|
|
privileged: true
|
|
|
|
depends_on:
|
|
|
|
- Test a build
|
|
|
|
environment:
|
|
|
|
GITEA_TOKEN:
|
2023-03-06 20:42:35 +00:00
|
|
|
from_secret: GITEA_TOKEN
|
|
|
|
commands:
|
2023-04-24 16:01:13 +00:00
|
|
|
- ./scripts/build-container.pl
|
2023-03-06 20:42:35 +00:00
|
|
|
|
|
|
|
- name: Sync pictures from lfs to Minio
|
2023-04-24 16:01:13 +00:00
|
|
|
image: git.badhouseplants.net/badhouseplants/badhouseplants-builder:80ffd53372652576fa3c36a56b351b448a025c6a
|
|
|
|
depends_on:
|
|
|
|
- Test a build
|
2023-03-06 20:42:35 +00:00
|
|
|
environment:
|
|
|
|
RCLONE_CONFIG_CONTENT:
|
|
|
|
from_secret: RCLONE_CONFIG_CONTENT_PRIVATE
|
|
|
|
RCLONE_CONFIG: /tmp/rclone.conf
|
|
|
|
commands:
|
|
|
|
- echo "$RCLONE_CONFIG_CONTENT" > $RCLONE_CONFIG
|
2023-03-29 16:13:55 +00:00
|
|
|
- ./scripts/upload-media.pl
|
2023-03-06 20:42:35 +00:00
|
|
|
|
|
|
|
- name: Deploy a preview ApplicationSet
|
2023-04-26 04:45:41 +00:00
|
|
|
image: git.badhouseplants.net/badhouseplants/badhouseplants-builder:80ffd53372652576fa3c36a56b351b448a025c6a
|
2023-03-06 20:42:35 +00:00
|
|
|
when:
|
|
|
|
branch:
|
|
|
|
exclude:
|
|
|
|
- main
|
2023-04-24 16:01:13 +00:00
|
|
|
depends_on:
|
|
|
|
- Build and push the docker image
|
|
|
|
- Sync pictures from lfs to Minio
|
2023-03-06 20:42:35 +00:00
|
|
|
environment:
|
|
|
|
KUBECONFIG_CONTENT:
|
|
|
|
from_secret: KUBECONFIG_CONTENT
|
|
|
|
commands:
|
|
|
|
- mkdir $HOME/.kube
|
|
|
|
- echo $KUBECONFIG_CONTENT | base64 -d > $HOME/.kube/config
|
|
|
|
- export ARGO_APP_CHART_VERSION=`cat chart/Chart.yaml | yq '.version'`
|
|
|
|
- export ARGO_APP_BRANCH=$DRONE_BRANCH
|
|
|
|
- export ARGO_APP_HOSTNAME="${DRONE_BRANCH}-dev.badhouseplants.net"
|
|
|
|
- export ARGO_APP_IMAGE_TAG=$DRONE_COMMIT_SHA
|
|
|
|
- export ARGO_REMARK42_SECRET=$(openssl rand -hex 12)
|
|
|
|
- kubectl get -f ./kube/applicationset.yaml -o yaml > /tmp/appset.yaml
|
|
|
|
- yq -i "del(.metadata.resourceVersion)" /tmp/appset.yaml
|
|
|
|
- yq -i "del(.metadata.generation)" /tmp/appset.yaml
|
|
|
|
- yq -i "del(.metadata.uid)" /tmp/appset.yaml
|
|
|
|
- yq -i "del(.status)" /tmp/appset.yaml
|
|
|
|
- yq -i "del(.spec.generators[].list.elements[] | select(.branch == \"$ARGO_APP_BRANCH\"))" /tmp/appset.yaml
|
|
|
|
- envsubst < ./kube/template.yaml > /tmp/elements.yaml
|
|
|
|
- yq -i '.spec.generators[].list.elements += load("/tmp/elements.yaml")' /tmp/appset.yaml
|
|
|
|
- kubectl apply -f /tmp/appset.yaml
|
|
|
|
|
|
|
|
- name: Deploy a main ApplicationSet
|
2023-04-26 04:45:41 +00:00
|
|
|
image: git.badhouseplants.net/badhouseplants/badhouseplants-builder:80ffd53372652576fa3c36a56b351b448a025c6a
|
2023-03-06 20:42:35 +00:00
|
|
|
when:
|
|
|
|
branch:
|
2023-02-25 20:25:16 +00:00
|
|
|
- main
|
2023-04-24 16:01:13 +00:00
|
|
|
depends_on:
|
|
|
|
- Build and push the docker image
|
|
|
|
- Sync pictures from lfs to Minio
|
2023-03-06 20:42:35 +00:00
|
|
|
environment:
|
|
|
|
KUBECONFIG_CONTENT:
|
|
|
|
from_secret: KUBECONFIG_CONTENT
|
|
|
|
ARGO_GITHUB_OAUTH_KEY:
|
|
|
|
from_secret: GITHUB_OAUTH_KEY
|
|
|
|
ARGO_GOOGLE_OAUTH_KEY:
|
|
|
|
from_secret: GOOGLE_OAUTH_KEY
|
|
|
|
commands:
|
|
|
|
- mkdir $HOME/.kube
|
|
|
|
- echo $KUBECONFIG_CONTENT | base64 -d > $HOME/.kube/config
|
|
|
|
- export ARGO_APP_CHART_VERSION=`cat chart/Chart.yaml | yq '.version'`
|
|
|
|
- export ARGO_APP_BRANCH=$DRONE_BRANCH
|
|
|
|
- export ARGO_APP_IMAGE_TAG=$DRONE_COMMIT_SHA
|
|
|
|
- kubectl get -f ./kube/applicationset.yaml -o yaml > /tmp/appset.yaml
|
|
|
|
- yq -i "del(.metadata.resourceVersion)" /tmp/appset.yaml
|
|
|
|
- yq -i "del(.metadata.generation)" /tmp/appset.yaml
|
|
|
|
- yq -i "del(.metadata.uid)" /tmp/appset.yaml
|
|
|
|
- yq -i "del(.status)" /tmp/appset.yaml
|
|
|
|
- yq -i "del(.spec.generators[].list.elements[] | select(.branch == \"$ARGO_APP_BRANCH\"))" /tmp/appset.yaml
|
|
|
|
- yq -i "del(.spec.generators[].list.elements[] | select(.commit_sha == \"$ARGO_APP_IMAGE_TAG\"))" /tmp/appset.yaml
|
2023-04-24 10:07:59 +00:00
|
|
|
- yq -i '. *= load("./kube/applicationset.yaml")' /tmp/appset.yaml
|
2023-03-06 20:42:35 +00:00
|
|
|
- envsubst < ./kube/main.yaml > /tmp/elements.yaml
|
|
|
|
- yq -i '.spec.generators[].list.elements += load("/tmp/elements.yaml")' /tmp/appset.yaml
|
|
|
|
- kubectl apply -f /tmp/appset.yaml
|
|
|
|
|
|
|
|
- name: Sync application
|
2023-04-26 04:45:41 +00:00
|
|
|
image: git.badhouseplants.net/badhouseplants/badhouseplants-builder:80ffd53372652576fa3c36a56b351b448a025c6a
|
2023-04-24 16:01:13 +00:00
|
|
|
depends_on:
|
|
|
|
- Deploy a main ApplicationSet
|
|
|
|
- Deploy a preview ApplicationSet
|
2023-03-06 20:42:35 +00:00
|
|
|
environment:
|
|
|
|
ARGOCD_SERVER:
|
|
|
|
from_secret: ARGOCD_SERVER
|
|
|
|
ARGOCD_AUTH_TOKEN:
|
|
|
|
from_secret: ARGOCD_AUTH_TOKEN
|
|
|
|
commands:
|
|
|
|
- argocd app sync -l app=badhouseplants -l branch=$DRONE_BRANCH
|
|
|
|
- argocd app wait -l app=badhouseplants -l branch=$DRONE_BRANCH
|
|
|
|
|
|
|
|
- name: Cleanup everything
|
2023-04-26 04:45:41 +00:00
|
|
|
image: git.badhouseplants.net/badhouseplants/badhouseplants-builder:80ffd53372652576fa3c36a56b351b448a025c6a
|
2023-04-24 16:01:13 +00:00
|
|
|
depends_on:
|
|
|
|
- Sync application
|
2023-03-06 20:42:35 +00:00
|
|
|
environment:
|
|
|
|
RCLONE_CONFIG_CONTENT:
|
|
|
|
from_secret: RCLONE_CONFIG_CONTENT_PRIVATE
|
|
|
|
RCLONE_CONFIG: /tmp/rclone.conf
|
|
|
|
GITEA_TOKEN:
|
|
|
|
from_secret: GITEA_TOKEN
|
2023-04-24 15:57:11 +00:00
|
|
|
ARGOCD_SERVER:
|
|
|
|
from_secret: ARGOCD_SERVER
|
|
|
|
ARGOCD_AUTH_TOKEN:
|
|
|
|
from_secret: ARGOCD_AUTH_TOKEN
|
2023-03-06 20:42:35 +00:00
|
|
|
commands:
|
|
|
|
- echo "$RCLONE_CONFIG_CONTENT" > $RCLONE_CONFIG
|
|
|
|
- ./scripts/cleanup.pl
|
2023-02-26 06:27:44 +00:00
|
|
|
|
2023-02-17 14:19:49 +00:00
|
|
|
---
|
2023-02-17 14:48:16 +00:00
|
|
|
# ----------------------------------------------
|
|
|
|
# -- Upload a newer version of my CV
|
|
|
|
# ----------------------------------------------
|
2023-02-17 14:19:49 +00:00
|
|
|
kind: pipeline
|
|
|
|
type: kubernetes
|
|
|
|
name: CV Builder
|
2023-02-17 14:48:16 +00:00
|
|
|
|
|
|
|
trigger:
|
2023-02-17 14:19:49 +00:00
|
|
|
branch:
|
|
|
|
- main
|
2023-02-17 14:48:16 +00:00
|
|
|
event:
|
|
|
|
- push
|
|
|
|
|
2023-02-17 14:19:49 +00:00
|
|
|
steps:
|
|
|
|
- name: Build the CV
|
|
|
|
image: ghcr.io/puppeteer/puppeteer
|
|
|
|
commands:
|
|
|
|
- cp -R ./content/cv/* $HOME
|
|
|
|
- cd $HOME
|
|
|
|
- npm install md-to-pdf
|
|
|
|
- npx md-to-pdf index.md
|
|
|
|
- mkdir $DRONE_WORKSPACE/cv
|
|
|
|
- mv index.pdf $DRONE_WORKSPACE/cv/n.rodionov.pdf
|
|
|
|
|
|
|
|
- name: Upload the CV
|
|
|
|
image: rclone/rclone:latest
|
|
|
|
environment:
|
|
|
|
RCLONE_CONFIG_CONTENT:
|
|
|
|
from_secret: RCLONE_CONFIG_CONTENT_PRIVATE
|
|
|
|
RCLONE_CONFIG: /tmp/rclone.conf
|
|
|
|
commands:
|
|
|
|
- echo "$RCLONE_CONFIG_CONTENT" > $RCLONE_CONFIG
|
|
|
|
- rclone copy -P $DRONE_WORKSPACE/cv badhouseplants-minio:/public-download
|