ContainerImage.JSONServer/.drone.yml

157 lines
4.7 KiB
YAML
Raw Permalink Normal View History

2023-05-10 09:42:08 +00:00
kind: pipeline
type: kubernetes
2023-07-11 13:15:41 +00:00
name: Container & Helm chart
trigger:
event:
exclude:
- tag
2023-05-10 09:42:08 +00:00
steps:
2023-07-11 13:15:41 +00:00
- name: Semantic Release (Dry-run)
image: bv11-cr01.bessems.eu/proxy/library/node:20-slim
pull: always
commands:
- |
apt-get update
- |
apt-get install -y --no-install-recommends \
git-core \
ca-certificates
- |
npm install \
semantic-release \
@semantic-release/commit-analyzer \
@semantic-release/exec \
- |
export GIT_CREDENTIALS=$${GIT_USERNAME}:$${GIT_APIKEY}
2023-07-11 13:15:41 +00:00
- |
npx semantic-release \
--package @semantic-release/exec \
--package semantic-release \
--branches ${DRONE_BRANCH} \
--tag-format "v\$${version}" \
--dry-run \
--plugins @semantic-release/commit-analyzer,@semantic-release/exec \
--analyzeCommits @semantic-release/commit-analyzer \
--verifyRelease @semantic-release/exec \
--verifyReleaseCmd 'echo "$${nextRelease.version}" > .version'
environment:
GIT_APIKEY:
from_secret: git_apikey
GIT_USERNAME: djpbessems
2023-07-11 13:37:29 +00:00
- name: Container image (Harbor)
depends_on:
2023-07-11 13:15:41 +00:00
- Semantic Release (Dry-run)
image: gcr.io/kaniko-project/executor:debug
2023-07-11 13:15:41 +00:00
pull: always
commands:
- |
export VALID_TAG=$(cat .version 2> /dev/null) && [ -n "$VALID_TAG" ] || (echo 'No release tag - exiting'; exit 0)
- |
wget https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux64 -qO /bin/jq
chmod +x /bin/jq
- |
2023-07-11 19:19:54 +00:00
/bin/jq '.auths["https://bv11-cr01.bessems.eu/v2/"].auth="'"$(echo -n $HARBOR_USERNAME':'$HARBOR_PASSWORD | base64)"'"' --null-input > /kaniko/.docker/config.json
- |
/kaniko/executor \
--dockerfile=Dockerfile \
--context=dir://. \
--destination=bv11-cr01.bessems.eu/library/json-server:latest \
--destination=bv11-cr01.bessems.eu/library/json-server:$VALID_TAG
environment:
2023-07-11 19:19:54 +00:00
HARBOR_USERNAME:
2023-05-10 09:42:08 +00:00
from_secret: harbor_username
2023-07-11 19:19:54 +00:00
HARBOR_PASSWORD:
2023-05-10 09:42:08 +00:00
from_secret: harbor_password
2023-07-11 13:15:41 +00:00
2023-07-11 13:37:29 +00:00
- name: Container image (docker.io)
depends_on:
2023-07-11 13:15:41 +00:00
- Semantic Release (Dry-run)
image: gcr.io/kaniko-project/executor:debug
2023-07-11 13:15:41 +00:00
pull: always
2023-07-11 13:30:47 +00:00
commands:
- |
export VALID_TAG=$(cat .version 2> /dev/null) && [ -n "$VALID_TAG" ] || (echo 'No release tag - exiting'; exit 0)
2023-07-11 13:30:47 +00:00
- |
wget https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux64 -qO /bin/jq
2023-07-11 15:26:40 +00:00
chmod +x /bin/jq
- |
/bin/jq '.auths["https://index.docker.io/v1/"].auth="'"$(echo -n $DOCKER_USERNAME':'$DOCKER_PASSWORD | base64)"'"' --null-input > /kaniko/.docker/config.json
- |
/kaniko/executor \
--dockerfile=Dockerfile \
--context=dir://. \
--destination=docker.io/djpbessems/json-server:latest \
--destination=docker.io/djpbessems/json-server:$VALID_TAG
environment:
DOCKER_USERNAME:
from_secret: docker_username
DOCKER_PASSWORD:
2023-05-10 09:42:08 +00:00
from_secret: docker_password
2023-05-10 10:06:38 +00:00
2023-07-11 13:37:29 +00:00
- name: Helm chart (Gitea)
2023-07-11 13:15:41 +00:00
depends_on:
- Semantic Release (Dry-run)
2023-05-10 10:06:38 +00:00
image: bv11-cr01.bessems.eu/proxy/alpine/helm
2023-07-11 13:15:41 +00:00
pull: always
2023-05-10 10:06:38 +00:00
commands:
2023-07-11 13:15:41 +00:00
- |
export VALID_TAG=$(cat .version 2> /dev/null) && [ -n "$VALID_TAG" ] || (echo 'No release tag - exiting'; exit 0)
sed -i 's/{{ chart_version }}/'$VALID_TAG'/g' charts/json-server/Chart.yaml
sed -i 's/{{ image_tag }}/'$VALID_TAG'/g' charts/json-server/values.yaml
2023-05-10 10:06:38 +00:00
- |
helm package ./charts/json-server
- |
2023-07-11 07:36:55 +00:00
helm plugin install https://github.com/chartmuseum/helm-push
- |
helm repo add \
--username $GIT_USERNAME \
--password $GIT_APIKEY \
spamasaurus \
https://code.spamasaurus.com/api/packages/$GIT_USERNAME/helm
- |
helm cm-push \
json-server-*.tgz \
spamasaurus
2023-05-10 10:06:38 +00:00
environment:
GIT_APIKEY:
from_secret: git_apikey
GIT_USERNAME: djpbessems
2023-07-11 13:15:41 +00:00
- name: Semantic Release
depends_on:
2023-07-11 13:38:16 +00:00
- Container image (Harbor)
- Container image (docker.io)
- Helm chart (Gitea)
2023-07-11 13:15:41 +00:00
image: bv11-cr01.bessems.eu/proxy/library/node:20-slim
pull: always
commands:
- |
export VALID_TAG=$(cat .version 2> /dev/null) && [ -n "$VALID_TAG" ] || (echo 'No release tag - exiting'; exit 0)
2023-07-11 13:15:41 +00:00
- |
apt-get update
- |
apt-get install -y --no-install-recommends \
git-core \
ca-certificates
- |
npm install \
semantic-release \
@semantic-release/changelog \
@semantic-release/commit-analyzer \
@semantic-release/git \
@semantic-release/release-notes-generator
- |
export GIT_CREDENTIALS=$${GIT_USERNAME}:$${GIT_APIKEY}
- |
npx semantic-release \
--branches ${DRONE_BRANCH} \
--tag-format "v\$${version}" \
--plugins @semantic-release/commit-analyzer,@semantic-release/release-notes-generator,@semantic-release/changelog,@semantic-release/git
environment:
GIT_APIKEY:
from_secret: git_apikey
GIT_USERNAME: djpbessems